Changeset 80 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Mar 10, 2006, 5:52:04 PM (16 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.