source: branches/replacing_gnuplot/lib/AddStats.cc @ 845

Last change on this file since 845 was 845, checked in by Jari Häkkinen, 14 years ago

Merged trunk changes -r782:844 to replacing_gnuplot branch.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// $Id: AddStats.cc 845 2009-11-16 22:27:19Z jari $
2
3/*
4  Copyright (C) 2008, 2009 Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "AddStats.h"
23
24#include "SVNblame.h"
25#include "SVNlog.h"
26#include "utility.h"
27
28#include <algorithm>
29#include <cassert>
30#include <cstdlib>
31#include <functional>
32#include <map>
33#include <string>
34#include <vector>
35
36namespace theplu{
37namespace svndigest{
38
39
40  AddStats::AddStats(const std::string& path)
41    : Stats(path)
42  {
43  }
44
45
46  AddStats::AddStats(const AddStats& other)
47  : Stats(other)
48  {
49  }
50
51
52  void AddStats::do_parse(const std::string& path, svn_revnum_t rev)
53  {
54    SVNlog log(path);
55    typedef std::set<svn_revnum_t, std::greater<svn_revnum_t> > RevSet;
56    RevSet revs;
57    std::transform(log.commits().begin(), log.commits().end(),
58                   std::inserter(revs, revs.begin()), 
59                   std::mem_fun_ref(&Commitment::revision));
60    for (RevSet::iterator rev_iter=revs.begin();
61         rev_iter!=revs.end() && *rev_iter>=rev; ++rev_iter){
62      SVNblame svn_blame(path, *rev_iter);
63      LineTypeParser parser(path);
64      while (svn_blame.valid()) {
65        LineTypeParser::line_type lt = parser.parse(svn_blame.line());
66        if (*rev_iter==svn_blame.revision())
67          add(svn_blame.author(), *rev_iter, lt);
68        // I dont trust blame and log behave consistently (stop-on-copy).
69        revs.insert(svn_blame.revision());
70        svn_blame.next_line();
71      }
72    }
73    accumulate_stats(rev);
74  }
75
76
77}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.