source: trunk/lib/ClassicStats.cc

Last change on this file was 1515, checked in by Peter Johansson, 9 years ago

update copyright years

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1// $Id: ClassicStats.cc 1515 2012-09-26 00:35:10Z peter $
2
3/*
4  Copyright (C) 2005 Peter Johansson
5  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2009, 2010, 2011, 2012 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 "ClassicStats.h"
25
26#include "Functor.h"
27#include "SVNblame.h"
28#include "SVNinfo.h"
29#include "utility.h"
30
31#include <algorithm>
32#include <cassert>
33#include <cstdlib>
34#include <fstream>
35#include <iostream>
36#include <iterator>
37#include <map>
38#include <numeric>
39#include <string>
40#include <sstream>
41#include <unistd.h>
42#include <utility>
43#include <vector>
44
45
46namespace theplu{
47namespace svndigest{
48
49
50  ClassicStats::ClassicStats(const std::string& path)
51    : Stats(path)
52  {
53  }
54
55
56  ClassicStats::ClassicStats(const ClassicStats& other)
57  : Stats(other)
58  {
59  }
60
61
62  void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev)
63  {
64    svn_revnum_t first_rev = ignore_rev() + 1;
65    reset();
66    LineTypeParser parser(path);
67    SVNblame svn_blame(path);
68    std::vector<std::map<std::string, SparseVector> > data(4);
69    while (svn_blame.valid()) {
70      LineTypeParser::line_type lt = parser.parse(svn_blame.line());
71      assert(static_cast<size_t>(lt)<data.size());
72      if (svn_blame.revision()>=first_rev) {
73        SparseVector& vec = data[lt][svn_blame.author()];
74        vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1);
75      }
76      svn_blame.next_line();
77    }
78    // add parsed data to member
79    add(data);
80  }
81
82
83  unsigned int
84  ClassicStats::max_element(const SumVector& v) const
85  {
86    if (v.size()==0)
87      return 0;
88    return v.back();
89  }
90
91}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.