Ignore:
Timestamp:
Apr 9, 2009, 10:18:54 PM (12 years ago)
Author:
Jari Häkkinen
Message:

Merged trunk changes r645:782 to replacing_gnuplot branch.

Location:
branches/replacing_gnuplot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/replacing_gnuplot

    • Property svn:ignore
      •  

        old new  
        88autom4te.cache
        99INSTALL
        10 COPYING
        1110aclocal.m4
        1211Makefile
  • branches/replacing_gnuplot/lib/File.cc

    r646 r784  
    33/*
    44  Copyright (C) 2005, 2006, 2007 Jari Häkkinen, Peter Johansson
    5 
    6   This file is part of svndigest, http://trac.thep.lu.se/svndigest
     5  Copyright (C) 2009 Peter Johansson
     6
     7  This file is part of svndigest, http://dev.thep.lu.se/svndigest
    78
    89  svndigest is free software; you can redistribute it and/or modify it
    910  under the terms of the GNU General Public License as published by
    10   the Free Software Foundation; either version 2 of the License, or
     11  the Free Software Foundation; either version 3 of the License, or
    1112  (at your option) any later version.
    1213
     
    1718
    1819  You should have received a copy of the GNU General Public License
    19   along with this program; if not, write to the Free Software
    20   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    21   02111-1307, USA.
     20  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2221*/
    2322
     
    5958
    6059
     60  std::string File::blame_output_file_name(void) const
     61  {
     62    return "blame_output/" + local_path() + ".html";
     63  }
     64
     65
    6166  std::map<int, std::set<Alias> >
    62   File::copyright_map(std::map<std::string, Alias>& alias) const
     67  File::copyright_map(std::map<std::string, Alias>& alias,
     68                      const std::map<int, svn_revnum_t>& year2rev) const
    6369  {
    6470    using namespace std;
    6571    map<int, set<Alias> > year_authors;
    66     SVNlog log(path());
    6772    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           ) {
     73
     74    // loop over all years
     75    for (std::map<int, svn_revnum_t>::const_iterator rev_iter=year2rev.begin();
     76         rev_iter!=year2rev.end(); ++rev_iter) {
     77
     78      svn_revnum_t last_rev_this_year = rev_iter->second;
     79      svn_revnum_t last_rev_last_year = 0;
     80      if (rev_iter != year2rev.begin()) {
     81        last_rev_last_year = (--rev_iter)->second;
     82        ++rev_iter;
     83      }
     84      // loop over authors
     85      for (std::set<std::string>::const_iterator a_iter=stats.authors().begin();
     86           a_iter!=stats.authors().end(); ++a_iter) {
     87
     88        // check if anything has been added since last year
     89        if ( (stats(LineTypeParser::code, *a_iter, last_rev_this_year) >
     90              stats(LineTypeParser::code, *a_iter, last_rev_last_year)) ||
     91             (stats(LineTypeParser::comment, *a_iter, last_rev_this_year) >
     92              stats(LineTypeParser::comment, *a_iter, last_rev_last_year)) ) {
    7793       
    78         time_t sec = str2time(i->date());
    79         tm* timeinfo = gmtime(&sec);
    8094       
    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));
     95          // find username in map of aliases
     96          std::map<string,Alias>::iterator name(alias.lower_bound(*a_iter));
     97         
     98          // if alias exist insert alias
     99          if (name != alias.end() && name->first==*a_iter)
     100            year_authors[rev_iter->first].insert(name->second);
     101          else {
     102            // else insert user name
     103            Alias a(*a_iter,alias.size());
     104            year_authors[rev_iter->first].insert(a);
     105            std::cerr << "svndigest: warning: no copyright alias found for `"
     106                      << *a_iter << "'\n";
     107            // insert alias to avoid multiple warnings.
     108            alias.insert(name, std::make_pair(*a_iter, a));
     109          }
    95110        }
    96111      }
     
    159174
    160175
    161   SVNlog File::log_core(void) const
    162   {
    163     return SVNlog(path());
     176  void File::log_core(SVNlog&) const
     177  {
    164178  }
    165179
     
    186200    if (!ignore && node_exist(cache_file)){
    187201      std::ifstream is(cache_file.c_str());
    188       if (stats_.load_cache(is)){
     202      if (stats_.load_cache(is)) {
     203        is.close();
    189204        return stats_;
    190205      }
    191206      is.close();
    192207    }
    193     else {
     208    else
    194209      stats_.parse(path_);
    195     }
    196210    if (!node_exist(cache_dir))
    197211      mkdir(cache_dir);
    198     std::ofstream os(cache_file.c_str());
     212    std::string tmp_cache_file(cache_file+"~");
     213    std::ofstream os(tmp_cache_file.c_str());
    199214    stats_.print(os);
    200215    os.close();
     216    rename(tmp_cache_file.c_str(), cache_file.c_str());
    201217    return stats_;
    202218  }
     
    205221  void File::print_blame(std::ofstream& os) const
    206222  {
    207     os << "<br /><h3>Blame Information</h3>";
     223    os << "<br /><h3>" << local_path() << "</h3>";
    208224    os << "<table class=\"blame\">\n";
    209225    os << "<thead>\n";
     
    286302
    287303  void File::print_copyright(std::map<std::string, Alias>& alias,
    288                              bool verbose) const
     304                             bool verbose,
     305                             const std::map<int,svn_revnum_t>& y2rev) const
    289306  {
    290307    if (ignore())
     
    301318      return;
    302319    }
    303     std::map<int, std::set<Alias> > map=copyright_map(alias);
     320    std::map<int, std::set<Alias> > map=copyright_map(alias, y2rev);
    304321    std::string new_block = copyright_block(map, prefix);
    305322    if (old_block==new_block)
     
    313330  void File::print_core(const bool verbose) const
    314331  {
     332    std::ofstream os(blame_output_file_name().c_str());
     333    assert(os.good());
     334    print_html_start(os, "svndigest", level_+1);
     335    print_blame(os);
     336    print_footer(os);
     337    os.close();
    315338  }
    316339
     
    343366    print_author_summary(os, stats_[stats_type], line_type, log);
    344367    os << "\n";
    345 
    346     print_blame(os);
     368    os << "<h3>"
     369       << anchor(blame_output_file_name(),
     370                 "Blame Information", level_+3)
     371       << "</h3>\n";
    347372
    348373    print_footer(os);
Note: See TracChangeset for help on using the changeset viewer.