source: trunk/lib/AddStats.cc @ 657

Last change on this file since 657 was 657, checked in by Peter Johansson, 13 years ago

Fix some problem with detection of copyright lines - fixes #275 and #328

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// $Id: AddStats.cc 657 2008-06-10 00:27:40Z peter $
2
3/*
4  Copyright (C) 2008 Peter Johansson
5
6  This file is part of svndigest, http://trac.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 2 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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
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
38//debug
39#include <iostream>
40
41namespace theplu{
42namespace svndigest{
43
44
45  AddStats::AddStats(const std::string& path)
46    : Stats(path)
47  {
48  }
49
50
51  AddStats::AddStats(const AddStats& other)
52  : Stats(other)
53  {
54  }
55
56
57  void AddStats::do_parse(const std::string& path)
58  {
59    SVNlog log(path);
60    typedef std::set<svn_revnum_t> RevSet;
61    RevSet revs;
62    std::transform(log.commits().begin(), log.commits().end(),
63                   std::inserter(revs, revs.begin()), 
64                   std::mem_fun_ref(&Commitment::revision));
65    for (RevSet::iterator rev_iter=revs.begin();rev_iter!=revs.end();++rev_iter){
66      SVNblame svn_blame(path, *rev_iter);
67      LineTypeParser parser(path);
68      while (svn_blame.valid()) {
69        LineTypeParser::line_type lt = parser.parse(svn_blame.line());
70        if (*rev_iter==svn_blame.revision())
71          add(svn_blame.author(), *rev_iter, lt);
72        // I dont trust blame and log behave consistent (stop-on-copy).
73        revs.insert(svn_blame.revision());
74        svn_blame.next_line();
75      }
76    }
77   
78    accumulate_stats();
79  }
80
81
82}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.