Changeset 703


Ignore:
Timestamp:
Nov 24, 2008, 4:58:58 AM (15 years ago)
Author:
Peter Johansson
Message:

fixed some issues that addresses #338. Want to add some tests before allowing --ignore-cache and closing ticket:338.

Location:
trunk/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/AddStats.cc

    r693 r703  
    6262                   std::mem_fun_ref(&Commitment::revision));
    6363    for (RevSet::iterator rev_iter=revs.begin();
    64          rev_iter!=revs.end() && *rev_iter>rev; ++rev_iter){
     64         rev_iter!=revs.end() && *rev_iter>=rev; ++rev_iter){
    6565      SVNblame svn_blame(path, *rev_iter);
    6666      LineTypeParser parser(path);
     
    7474      }
    7575    }
    76    
    7776    accumulate_stats(rev);
    7877  }
  • trunk/lib/BlameStats.cc

    r700 r703  
    8383                   std::mem_fun_ref(&Commitment::revision));
    8484    for (RevSet::reverse_iterator rev_iter=revs.rbegin();
    85          rev_iter!=revs.rend() && *rev_iter>first_rev; ++rev_iter){
     85         rev_iter!=revs.rend() && *rev_iter>=first_rev; ++rev_iter){
    8686      SVNblame svn_blame(path, *rev_iter);
    8787      LineTypeParser parser(path);
  • trunk/lib/ClassicStats.cc

    r693 r703  
    6161  void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev)
    6262  {
    63     // we only call blame once so we can ignore rev here
    6463    LineTypeParser parser(path);
    6564    SVNblame svn_blame(path);
    6665    while (svn_blame.valid()) {
    67       add(svn_blame.author(), svn_blame.revision(),
    68           parser.parse(svn_blame.line()));
     66      if (svn_blame.revision()>=rev) {
     67        add(svn_blame.author(), svn_blame.revision(),
     68            parser.parse(svn_blame.line()));
     69      }
    6970      svn_blame.next_line();
    7071    }
    71     accumulate_stats();
    72 
     72    accumulate_stats(rev);
    7373  }
    7474
  • trunk/lib/Stats.cc

    r693 r703  
    6767                         svn_revnum_t rev) const
    6868  {
     69    assert(rev>0);
    6970    if (vec.empty()){
    7071      // just to allow call to vec.back() below
    7172      vec.resize(1,0);
    7273    }
    73     else if (vec.begin()+rev < vec.end())
    74       std::partial_sum(vec.begin()+rev,vec.end(),vec.begin()+rev);
     74    else if (vec.begin()+rev-1 < vec.end())
     75      std::partial_sum(vec.begin()+rev-1,vec.end(),vec.begin()+rev-1);
    7576    // static_cast to remove annoying compiler warning
    7677    if (vec.size() < static_cast<size_t>(revision()+1))
     
    8182  void Stats::accumulate_stats(svn_revnum_t rev)
    8283  {
     84    if (!rev)
     85      rev = 1;
    8386    for (std::set<std::string>::const_iterator iter(authors().begin());
    8487         iter!=authors().end(); ++iter) {
  • trunk/lib/Stats.h

    r701 r703  
    9999
    100100    /**
    101        Do the parsing for \a path. The function will only parse out
    102        stats for revisions larger than \a rev.
     101       Do the parsing for \a path. Revisions from \a rv will be parsed.
    103102    */
    104103    void parse(const std::string& path, svn_revnum_t rev=0);
     
    148147    typedef Author2Vector::const_iterator A2VConstIter;
    149148
    150     void accumulate_stats(svn_revnum_t rev=0);
     149    /**
     150       Calculate accumalated statistics for fundamental statistics,
     151       i.e., code, comment, empty, and copyright for each author.
     152       \see accumulate
     153     */
     154    void accumulate_stats(svn_revnum_t rev=1);
    151155    void add_author(std::string);
    152156    void add_authors(std::set<std::string>::const_iterator,
     
    198202                                         std::string user) const;
    199203  private:
     204    /**
     205       \a vec is resized to revision().
     206       vec is accumulated such that
     207       vec[rev] = vec[rev-1] + vec[rev]
     208       vec[rev+1] = vec[rev] + vec[rev+1]
     209       et cetera
     210     */
    200211    void accumulate(std::vector<unsigned int>& vec,
    201                     svn_revnum_t rev=0) const;
     212                    svn_revnum_t rev=1) const;
    202213    void add(std::vector<unsigned int>& vec, unsigned int rev, bool x,
    203214             unsigned int n);
    204215
    205     virtual void do_parse(const std::string&, svn_revnum_t)=0;
     216    /**
     217       Parse statistics for fundamental categories, i.e., code,
     218       comment, empty, and copyright for each author. Ignore revisions
     219       earlier than \a first_rev.
     220     */
     221    virtual void do_parse(const std::string&, svn_revnum_t first_rev)=0;
    206222   
    207223    // Change this string if cache format is changed in such a way
  • trunk/lib/StatsCollection.cc

    r702 r703  
    6767        if (!cache_rev)
    6868          i->second->reset();
    69         i->second->parse(path_, cache_rev);
     69        i->second->parse(path_, cache_rev+1);
    7070      }
    7171    }
Note: See TracChangeset for help on using the changeset viewer.