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