Last change
on this file since 63 was
63,
checked in by Peter Johansson, 17 years ago
|
Fixed problem with mapping revison to date. Removed mkstemps. name of
png files are now in line with their html file name. Binary works on
svnstat, but is asserted on c++_tools.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.6 KB
|
Line | |
---|
1 | |
---|
2 | //$Id: CommitStat.cc 63 2006-01-19 23:07:36Z peter $ |
---|
3 | |
---|
4 | #include "CommitStat.h" |
---|
5 | |
---|
6 | #include <algorithm> |
---|
7 | #include <fstream> |
---|
8 | #include <iostream> |
---|
9 | #include <sstream> |
---|
10 | #include <string> |
---|
11 | |
---|
12 | namespace theplu{ |
---|
13 | namespace svnstat{ |
---|
14 | |
---|
15 | int CommitStat::log(const std::string& path) const |
---|
16 | { |
---|
17 | std::string system_call = "svn log -q -r HEAD:1 " + path + |
---|
18 | " > svnstat.log.tmp"; |
---|
19 | int system_return = system(system_call.c_str()); |
---|
20 | if (system_return) |
---|
21 | std::cerr << "Error: svn log " << path << std::endl; |
---|
22 | return system_return; |
---|
23 | } |
---|
24 | |
---|
25 | |
---|
26 | int CommitStat::parse(const std::string& path) |
---|
27 | { |
---|
28 | reset(); |
---|
29 | int system_return = log(path); |
---|
30 | |
---|
31 | std::ifstream is("svnstat.log.tmp"); |
---|
32 | std::string line; |
---|
33 | typedef std::vector<std::string>::iterator DateIter; |
---|
34 | size_t rev_last_iteration=0; |
---|
35 | std::string date; |
---|
36 | while (getline(is,line, '\n')){ |
---|
37 | if (!line.size()) // skip empty line |
---|
38 | continue; |
---|
39 | std::stringstream ss(line); |
---|
40 | |
---|
41 | if (ss.get() == 'r'){ |
---|
42 | size_t revision; |
---|
43 | ss >> revision; |
---|
44 | assert(revision); |
---|
45 | std::string tmp; |
---|
46 | ss >> tmp; |
---|
47 | std::string user; |
---|
48 | ss >> user; |
---|
49 | ss >> tmp; |
---|
50 | ss >> date; |
---|
51 | std::string time; |
---|
52 | ss >> time; |
---|
53 | |
---|
54 | if (revision+1 > date_.size()){ |
---|
55 | date_.resize(revision+1); |
---|
56 | rev_last_iteration=revision+1; |
---|
57 | } |
---|
58 | assert(revision<=rev_last_iteration); |
---|
59 | std::fill(date_.begin()+revision, |
---|
60 | date_.begin()+rev_last_iteration, |
---|
61 | date); |
---|
62 | rev_last_iteration=revision; |
---|
63 | } |
---|
64 | std::fill(date_.begin(), |
---|
65 | date_.begin()+rev_last_iteration, |
---|
66 | date); |
---|
67 | } |
---|
68 | is.close(); |
---|
69 | |
---|
70 | return system_return; |
---|
71 | } |
---|
72 | |
---|
73 | |
---|
74 | void CommitStat::reset(void) |
---|
75 | { |
---|
76 | date_.clear(); |
---|
77 | } |
---|
78 | |
---|
79 | }} // end of namespace svnstat and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.