source: trunk/lib/AddStats.cc @ 978

Last change on this file since 978 was 978, checked in by Peter Johansson, 12 years ago

refs #429. Convert copyright statements to UTF-8

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