Changeset 61


Ignore:
Timestamp:
Jan 19, 2006, 2:32:57 PM (16 years ago)
Author:
Peter Johansson
Message:

fixed the problem with parsing from log?

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/CommitStat.cc

    r60 r61  
     1
    12//$Id$
    23
     
    1415  int CommitStat::log(const std::string& path) const
    1516  {
    16     std::string system_call = "svn log -q " + path + " > svnstat.log.tmp";
    17     std::cout << system_call << std::endl;
    18     int system_return = system(system_call.c_str());
     17    std::string system_call = "svn log -q -r HEAD:1 " + path +
     18      " > svnstat.log.tmp";
     19    int system_return = system(system_call.c_str());
    1920    if (system_return)
    2021      std::cerr << "Error: svn log " << path << std::endl;     
     
    3031    std::ifstream is("svnstat.log.tmp");
    3132    std::string line;
     33    typedef std::vector<std::string>::iterator DateIter;
     34    size_t rev_last_iteration=0;
    3235    while (getline(is,line, '\n')){
    3336      if (!line.size()) // skip empty line
     
    3841        size_t revision;
    3942        ss >> revision;
     43        assert(revision);
     44         
    4045        std::string tmp;
    4146        ss >> tmp;
     
    4853        ss >> time;
    4954
    50         date_.resize(std::max(revision+1, date_.size()));
    51         date_[revision] = date;
     55        if (revision+1 > date_.size()){
     56          date_.resize(revision+1);
     57          rev_last_iteration=revision;
     58        }
     59        assert(revision<=rev_last_iteration);
     60        std::copy(date_.begin()+revision,
     61                  date_.begin()+rev_last_iteration,
     62                  date_.begin()+revision);
     63        rev_last_iteration=revision;
    5264      }
     65      std::copy(date_.begin(),
     66                date_.begin()+rev_last_iteration,
     67                date_.begin());
    5368    }
    5469    is.close();
    5570   
    56     for(std::vector<std::string>::reverse_iterator i=date_.rbegin();
    57         i!=date_.rend(); ++i)
    58       if (i->empty()){
    59         assert(i!=date_.rbegin());
    60         *i = *(i-1);
    61       }
    62 
    6371    return system_return;
    6472  }
  • trunk/lib/CommitStat.h

    r60 r61  
    2222
    2323    ///
    24     /// Function parsing output from 'svn log \a path'.
     24    /// Function parsing output from log() \a path'.
    2525    ///
    2626    /// @return return value from system call
     
    3232  private:
    3333    ///
    34     /// @return return value from 'svn log \a path'
     34    /// @return return value from 'svn log -q -r 1:HEAD \a path'
    3535    ///
    3636    int log(const std::string& path) const;
Note: See TracChangeset for help on using the changeset viewer.