source: trunk/lib/AddStats.cc @ 552

Last change on this file since 552 was 552, checked in by Peter Johansson, 14 years ago

fixes linetype Copyright

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