Last change
on this file since 7 was
7,
checked in by Jari Häkkinen, 17 years ago
|
Fixed svn properties. Moved endo of namespace comments to correct line.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id
|
File size:
1.4 KB
|
Line | |
---|
1 | // $Id: File.cc 7 2005-12-30 06:41:11Z jari $ |
---|
2 | |
---|
3 | #include "File.h" |
---|
4 | #include "Node.h" |
---|
5 | |
---|
6 | #include <fstream> |
---|
7 | #include <iostream> |
---|
8 | #include <sstream> |
---|
9 | #include <string> |
---|
10 | #include <vector> |
---|
11 | |
---|
12 | namespace theplu{ |
---|
13 | namespace svnstat{ |
---|
14 | |
---|
15 | File::File(const std::string& path, Node* mother) |
---|
16 | : Node(path,mother), binary_(false) |
---|
17 | { |
---|
18 | } |
---|
19 | |
---|
20 | bool File::blame() const |
---|
21 | { |
---|
22 | std::string system_call = "svn blame " + path_ + " > svnstat.tmp"; |
---|
23 | int system_return = system(system_call.c_str()); |
---|
24 | if (system_return) |
---|
25 | std::cerr << "Error: svn blame " << path_ << std::endl; |
---|
26 | return !system_return; |
---|
27 | } |
---|
28 | |
---|
29 | bool File::parse(void) |
---|
30 | { |
---|
31 | if (binary_){ |
---|
32 | add(author_,revision_); |
---|
33 | return true; |
---|
34 | } |
---|
35 | |
---|
36 | // Calling svn blame |
---|
37 | if (!blame()) |
---|
38 | return false; |
---|
39 | |
---|
40 | // Check if file is binary |
---|
41 | std::ifstream is("svnstat.tmp"); |
---|
42 | std::string line; |
---|
43 | getline(is,line,' '); |
---|
44 | if (line==std::string("Skipping")){ |
---|
45 | getline(is,line,' '); |
---|
46 | if (line==std::string("binary")){ |
---|
47 | is.close(); |
---|
48 | binary_ = true; |
---|
49 | return parse(); |
---|
50 | } |
---|
51 | } |
---|
52 | is.close(); |
---|
53 | |
---|
54 | is.open("svnstat.tmp"); |
---|
55 | while (getline(is,line, '\n')){ |
---|
56 | if (!line.size()) // skip empty line |
---|
57 | continue; |
---|
58 | std::stringstream ss(line); |
---|
59 | u_int revision; |
---|
60 | std::string user; |
---|
61 | ss >> revision; |
---|
62 | ss >> user; |
---|
63 | add(user, revision); |
---|
64 | } |
---|
65 | is.close(); |
---|
66 | return true; |
---|
67 | } |
---|
68 | |
---|
69 | }} // end of namespace svnstat and namespace theplu |
---|
Note: See
TracBrowser
for help on using the repository browser.