source: trunk/lib/utility.cc @ 74

Last change on this file since 74 was 62, checked in by Peter Johansson, 16 years ago

oops

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.0 KB
Line 
1// $Id: utility.cc 62 2006-01-19 20:41:22Z peter $
2
3#include "utility.h"
4
5#include <fstream>
6#include <iostream>
7#include <map>
8#include <sstream>
9#include <string>
10
11namespace theplu{
12namespace svnstat{
13
14  int blame(const std::string& path)
15  {
16    std::string system_call = "svn blame " + path + " > svnstat.tmp";
17    int system_return = system(system_call.c_str());
18    if (system_return)
19      std::cerr << "Error: svn blame " << path << std::endl;     
20    return system_return;
21  }
22
23  std::map<std::string, std::string> info(const std::string& path) 
24  {
25    std::string system_call = "svn info " + path + " > svnstat.tmp";
26    int system_return = system(system_call.c_str());
27    if (system_return){
28      // Jari, throw exception.
29      std::cerr << "svnstat: svn info " << path << std::endl;     
30      exit(-1);
31    }
32
33    std::ifstream is("svnstat.tmp");
34    std::string line;
35    std::map<std::string, std::string> svn_info;
36    while (getline(is,line)){
37      std::stringstream ss(line);
38      std::string tag;
39      getline(ss,tag,':');
40      ss >> svn_info[tag];
41    }
42    return  svn_info;
43  }
44
45}} // end of namespace svnstat and namespace theplu
Note: See TracBrowser for help on using the repository browser.