source: trunk/lib/AddStats.cc @ 693

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

Fixes #339. Change to GPLv3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// $Id: AddStats.cc 693 2008-09-11 20:42:56Z jari $
2
3/*
4  Copyright (C) 2008 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
36//debug
37#include <iostream>
38
39namespace theplu{
40namespace svndigest{
41
42
43  AddStats::AddStats(const std::string& path)
44    : Stats(path)
45  {
46  }
47
48
49  AddStats::AddStats(const AddStats& other)
50  : Stats(other)
51  {
52  }
53
54
55  void AddStats::do_parse(const std::string& path, svn_revnum_t rev)
56  {
57    SVNlog log(path);
58    typedef std::set<svn_revnum_t, std::greater<svn_revnum_t> > RevSet;
59    RevSet revs;
60    std::transform(log.commits().begin(), log.commits().end(),
61                   std::inserter(revs, revs.begin()), 
62                   std::mem_fun_ref(&Commitment::revision));
63    for (RevSet::iterator rev_iter=revs.begin();
64         rev_iter!=revs.end() && *rev_iter>rev; ++rev_iter){
65      SVNblame svn_blame(path, *rev_iter);
66      LineTypeParser parser(path);
67      while (svn_blame.valid()) {
68        LineTypeParser::line_type lt = parser.parse(svn_blame.line());
69        if (*rev_iter==svn_blame.revision())
70          add(svn_blame.author(), *rev_iter, lt);
71        // I dont trust blame and log behave consistent (stop-on-copy).
72        revs.insert(svn_blame.revision());
73        svn_blame.next_line();
74      }
75    }
76   
77    accumulate_stats(rev);
78  }
79
80
81}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.