Last change
on this file since 60 was
60,
checked in by Peter Johansson, 16 years ago
|
plotting vs date rather than revision
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Line | |
---|
1 | //$Id: CommitStat.cc 60 2006-01-16 10:03:04Z peter $ |
---|
2 | |
---|
3 | #include "CommitStat.h" |
---|
4 | |
---|
5 | #include <algorithm> |
---|
6 | #include <fstream> |
---|
7 | #include <iostream> |
---|
8 | #include <sstream> |
---|
9 | #include <string> |
---|
10 | |
---|
11 | namespace theplu{ |
---|
12 | namespace svnstat{ |
---|
13 | |
---|
14 | int CommitStat::log(const std::string& path) const |
---|
15 | { |
---|
16 | std::string system_call = "svn log -q " + path + " > svnstat.log.tmp"; |
---|
17 | std::cout << system_call << std::endl; |
---|
18 | int system_return = system(system_call.c_str()); |
---|
19 | if (system_return) |
---|
20 | std::cerr << "Error: svn log " << path << std::endl; |
---|
21 | return system_return; |
---|
22 | } |
---|
23 | |
---|
24 | |
---|
25 | int CommitStat::parse(const std::string& path) |
---|
26 | { |
---|
27 | reset(); |
---|
28 | int system_return = log(path); |
---|
29 | |
---|
30 | std::ifstream is("svnstat.log.tmp"); |
---|
31 | std::string line; |
---|
32 | while (getline(is,line, '\n')){ |
---|
33 | if (!line.size()) // skip empty line |
---|
34 | continue; |
---|
35 | std::stringstream ss(line); |
---|
36 | |
---|
37 | if (ss.get() == 'r'){ |
---|
38 | size_t revision; |
---|
39 | ss >> revision; |
---|
40 | std::string tmp; |
---|
41 | ss >> tmp; |
---|
42 | std::string user; |
---|
43 | ss >> user; |
---|
44 | ss >> tmp; |
---|
45 | std::string date; |
---|
46 | ss >> date; |
---|
47 | std::string time; |
---|
48 | ss >> time; |
---|
49 | |
---|
50 | date_.resize(std::max(revision+1, date_.size())); |
---|
51 | date_[revision] = date; |
---|
52 | } |
---|
53 | } |
---|
54 | is.close(); |
---|
55 | |
---|
56 | for(std::vector<std::string>::reverse_iterator i=date_.rbegin(); |
---|
57 | i!=date_.rend(); ++i) |
---|
58 | if (i->empty()){ |
---|
59 | assert(i!=date_.rbegin()); |
---|
60 | *i = *(i-1); |
---|
61 | } |
---|
62 | |
---|
63 | return system_return; |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | }} // end of namespace svnstat and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.