source: trunk/lib/File.cc @ 15

Last change on this file since 15 was 15, checked in by Peter Johansson, 17 years ago

removed superfluous includes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1// $Id: File.cc 15 2005-12-30 17:04:16Z peter $
2
3#include "File.h"
4#include "Node.h"
5#include "Stats.h"
6
7#include <fstream>
8#include <iostream>
9#include <sstream>
10#include <string>
11
12namespace theplu{
13namespace 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  const Stats& File::parse(void)
25  {
26    // calling svn info
27    info();
28    stats_.reset();
29    if (binary_){
30      stats_.add(author_,revision_);
31      return stats_;
32    }
33
34    // Calling svn blame
35    if (!blame())
36      return stats_;
37
38    // Check if file is binary
39    std::ifstream is("svnstat.tmp");
40    std::string line;
41    getline(is,line,' ');
42    if (line==std::string("Skipping")){
43      getline(is,line,' ');
44      if (line==std::string("binary")){
45  is.close();
46  binary_ = true;
47  return parse();
48      }
49    }
50    is.close();
51
52    is.open("svnstat.tmp");
53    while (getline(is,line, '\n')){
54      if (!line.size()) // skip empty line
55  continue;
56      std::stringstream ss(line);
57      u_int revision;
58      std::string user;
59      ss >> revision;
60      ss >> user;
61      stats_.add(user, revision);
62    }
63    is.close();
64    return stats_;
65  }
66
67  void File::print(void) {
68    // Jari, temporary using this to print directory tree
69    std::cout << "File '" << path_ << "'" << std::endl;
70  }
71
72}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.