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