Changeset 654 for trunk/lib/File.cc


Ignore:
Timestamp:
Jun 8, 2008, 6:58:38 AM (15 years ago)
Author:
Peter Johansson
Message:

Hopefully fixes #328 - need to be tested though

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/File.cc

    r653 r654  
    6060
    6161  std::map<int, std::set<Alias> >
    62   File::copyright_map(std::map<std::string, Alias>& alias) const
     62  File::copyright_map(std::map<std::string, Alias>& alias,
     63                      const std::map<int, svn_revnum_t>& year2rev) const
    6364  {
    6465    using namespace std;
    6566    map<int, set<Alias> > year_authors;
    66     SVNlog log(path());
    6767    const Stats& stats = stats_["add"];
    68    
    69     typedef std::vector<Commitment>::iterator LogIterator;
    70     for (LogIterator i=log.commits().begin(); i<log.commits().end(); ++i){
    71       if (i->revision() &&
    72           (stats(LineTypeParser::code, i->author(), i->revision()) >
    73            stats(LineTypeParser::code, i->author(), i->revision()-1) ||
    74            stats(LineTypeParser::comment, i->author(), i->revision()) >
    75            stats(LineTypeParser::comment, i->author(), i->revision()-1))
    76           ) {
     68
     69    // loop over all years
     70    for (std::map<int, svn_revnum_t>::const_iterator rev_iter=year2rev.begin();
     71         rev_iter!=year2rev.end(); ++rev_iter) {
     72
     73      svn_revnum_t last_rev_this_year = rev_iter->second;
     74      svn_revnum_t last_rev_last_year = 0;
     75      if (rev_iter != year2rev.begin()) {
     76        last_rev_last_year = (--rev_iter)->second;
     77        ++rev_iter;
     78      }
     79      // loop over authors
     80      for (std::set<std::string>::const_iterator a_iter=stats.authors().begin();
     81           a_iter!=stats.authors().end(); ++a_iter) {
     82
     83        // check if anything has been added since last year
     84        if ( (stats(LineTypeParser::code, *a_iter, last_rev_this_year) >
     85              stats(LineTypeParser::code, *a_iter, last_rev_last_year)) ||
     86             (stats(LineTypeParser::comment, *a_iter, last_rev_this_year) >
     87              stats(LineTypeParser::comment, *a_iter, last_rev_last_year)) ) {
    7788       
    78         time_t sec = str2time(i->date());
    79         tm* timeinfo = gmtime(&sec);
    8089       
    81         // find username in map of aliases
    82         std::map<string,Alias>::iterator name(alias.lower_bound(i->author()));
    83        
    84         // if alias exist insert alias
    85         if (name != alias.end() && name->first==i->author())
    86           year_authors[timeinfo->tm_year].insert(name->second);
    87         else {
    88           // else insert user name
    89           Alias a(i->author(),alias.size());
    90           year_authors[timeinfo->tm_year].insert(a);
    91           std::cerr << "svndigest: warning: no copyright alias found for `"
    92                     << i->author() << "'\n";
    93           // insert alias to avoid multiple warnings.
    94           alias.insert(name, std::make_pair(i->author(), a));
     90          // find username in map of aliases
     91          std::map<string,Alias>::iterator name(alias.lower_bound(*a_iter));
     92         
     93          // if alias exist insert alias
     94          if (name != alias.end() && name->first==*a_iter)
     95            year_authors[rev_iter->first].insert(name->second);
     96          else {
     97            // else insert user name
     98            Alias a(*a_iter,alias.size());
     99            year_authors[rev_iter->first].insert(a);
     100            std::cerr << "svndigest: warning: no copyright alias found for `"
     101                      << *a_iter << "'\n";
     102            // insert alias to avoid multiple warnings.
     103            alias.insert(name, std::make_pair(*a_iter, a));
     104          }
    95105        }
    96106      }
     
    302312      return;
    303313    }
    304     std::map<int, std::set<Alias> > map=copyright_map(alias);
     314    std::map<int, std::set<Alias> > map=copyright_map(alias, y2rev);
    305315    std::string new_block = copyright_block(map, prefix);
    306316    if (old_block==new_block)
Note: See TracChangeset for help on using the changeset viewer.