1 | // $Id: ClassicStats.cc 1276 2010-11-05 12:24:26Z 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 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 | |
---|
46 | namespace theplu{ |
---|
47 | namespace 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 | reset(); |
---|
65 | LineTypeParser parser(path); |
---|
66 | SVNblame svn_blame(path); |
---|
67 | std::vector<std::map<std::string, SparseVector> > data(4); |
---|
68 | while (svn_blame.valid()) { |
---|
69 | LineTypeParser::line_type lt = parser.parse(svn_blame.line()); |
---|
70 | assert(lt<data.size()); |
---|
71 | SparseVector& vec = data[lt][svn_blame.author()]; |
---|
72 | vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1); |
---|
73 | svn_blame.next_line(); |
---|
74 | } |
---|
75 | // add parsed data to member |
---|
76 | add(data); |
---|
77 | } |
---|
78 | |
---|
79 | |
---|
80 | unsigned int |
---|
81 | ClassicStats::max_element(const SumVector& v) const |
---|
82 | { |
---|
83 | if (v.size()==0) |
---|
84 | return 0; |
---|
85 | return v.back(); |
---|
86 | } |
---|
87 | |
---|
88 | }} // end of namespace svndigest and namespace theplu |
---|