Changeset 80


Ignore:
Timestamp:
Mar 10, 2006, 5:52:04 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Removed nasty bug: svnstat crashed when the last checkin contained zero statistics
count items only, eg. empty directories or binary files.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Node.h

    r79 r80  
    2222    /// @brief Constructor
    2323    ///
    24     Node(const std::string& path, const std::string& output="") : path_(path)
     24    Node(const std::string& path, const std::string& output="")
     25      : path_(path), stats_(path)
    2526      { output_name_ = output + name(); }
    2627
  • trunk/lib/Stats.cc

    r78 r80  
    2222namespace svnstat{
    2323
    24   u_int Stats::latest_revision_=0;
     24
     25  Stats::Stats(const std::string& path)
     26  {
     27    // Make sure latest revision is set properly
     28    std::map<std::string,std::string> svn_info = info(path);
     29    std::stringstream ss;
     30    ss << (svn_info.count("Revision") ? svn_info["Revision"] : "0");
     31    ss >> latest_revision_;
     32  }
     33
    2534
    2635  std::vector<u_int> Stats::accumulated(void) const
     
    5665    std::vector<u_int>* vec = &(map_[user]);
    5766    if (vec->size() < rev+1){
    58       vec->reserve(rev+1);
     67      vec->reserve(latest_revision_ + 1);
    5968      vec->insert(vec->end(), rev - vec->size(),0);
    6069      vec->push_back(1);
    61       latest_revision_ = std::max(latest_revision_,rev);
    6270    }
    6371    else
  • trunk/lib/Stats.h

    r74 r80  
    2222    /// @brief Default Constructor
    2323    ///
    24     inline Stats(void) {}
     24    explicit Stats(const std::string& path);
    2525
    2626    ///
     
    7070    void add(const std::string& user, const u_int& revision);
    7171
    72     static u_int latest_revision_; // latest revision for whole project
     72
     73    u_int latest_revision_; // Should be the latest revision for whole project
    7374
    7475    // Peter, if the vector is sparse make it a map
  • trunk/lib/utility.cc

    r62 r80  
    1414  int blame(const std::string& path)
    1515  {
    16     std::string system_call = "svn blame " + path + " > svnstat.tmp";
     16    std::string system_call="svn blame " + path + " 1> svnstat.tmp 2> /dev/null";
    1717    int system_return = system(system_call.c_str());
    1818    if (system_return)
     
    2323  std::map<std::string, std::string> info(const std::string& path)
    2424  {
    25     std::string system_call = "svn info " + path + " > svnstat.tmp";
     25    std::string system_call="svn info " + path + " 1> svnstat.tmp 2> /dev/null";
    2626    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     }
     27    if (system_return)
     28      return std::map<std::string, std::string>();
    3229
    3330    std::ifstream is("svnstat.tmp");
Note: See TracChangeset for help on using the changeset viewer.