84 |
13 Mar 06 |
jari |
// $Id$ |
14 |
30 Dec 05 |
peter |
2 |
|
84 |
13 Mar 06 |
jari |
3 |
/* |
84 |
13 Mar 06 |
jari |
Copyright (C) 2005 Peter Johansson |
978 |
12 Dec 09 |
peter |
Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2009, 2010, 2011, 2012, 2023 Peter Johansson |
84 |
13 Mar 06 |
jari |
7 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
84 |
13 Mar 06 |
jari |
9 |
|
149 |
12 Aug 06 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
84 |
13 Mar 06 |
jari |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
84 |
13 Mar 06 |
jari |
(at your option) any later version. |
84 |
13 Mar 06 |
jari |
14 |
|
149 |
12 Aug 06 |
jari |
svndigest is distributed in the hope that it will be useful, but |
84 |
13 Mar 06 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
149 |
12 Aug 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
84 |
13 Mar 06 |
jari |
General Public License for more details. |
84 |
13 Mar 06 |
jari |
19 |
|
84 |
13 Mar 06 |
jari |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
84 |
13 Mar 06 |
jari |
22 |
*/ |
84 |
13 Mar 06 |
jari |
23 |
|
1619 |
12 Mar 23 |
peter |
24 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
25 |
|
487 |
13 Oct 07 |
peter |
26 |
#include "ClassicStats.h" |
129 |
02 Aug 06 |
jari |
27 |
|
465 |
24 Aug 07 |
peter |
28 |
#include "Functor.h" |
138 |
03 Aug 06 |
jari |
29 |
#include "SVNblame.h" |
129 |
02 Aug 06 |
jari |
30 |
#include "SVNinfo.h" |
14 |
30 Dec 05 |
peter |
31 |
#include "utility.h" |
14 |
30 Dec 05 |
peter |
32 |
|
41 |
13 Jan 06 |
peter |
33 |
#include <algorithm> |
65 |
20 Jan 06 |
peter |
34 |
#include <cassert> |
63 |
19 Jan 06 |
peter |
35 |
#include <cstdlib> |
454 |
18 Aug 07 |
peter |
36 |
#include <fstream> |
60 |
16 Jan 06 |
peter |
37 |
#include <iostream> |
454 |
18 Aug 07 |
peter |
38 |
#include <iterator> |
14 |
30 Dec 05 |
peter |
39 |
#include <map> |
14 |
30 Dec 05 |
peter |
40 |
#include <numeric> |
14 |
30 Dec 05 |
peter |
41 |
#include <string> |
138 |
03 Aug 06 |
jari |
42 |
#include <sstream> |
44 |
13 Jan 06 |
jari |
43 |
#include <unistd.h> |
23 |
02 Jan 06 |
peter |
44 |
#include <utility> |
14 |
30 Dec 05 |
peter |
45 |
#include <vector> |
14 |
30 Dec 05 |
peter |
46 |
|
63 |
19 Jan 06 |
peter |
47 |
|
14 |
30 Dec 05 |
peter |
48 |
namespace theplu{ |
149 |
12 Aug 06 |
jari |
49 |
namespace svndigest{ |
14 |
30 Dec 05 |
peter |
50 |
|
14 |
30 Dec 05 |
peter |
51 |
|
487 |
13 Oct 07 |
peter |
52 |
ClassicStats::ClassicStats(const std::string& path) |
487 |
13 Oct 07 |
peter |
53 |
: Stats(path) |
80 |
10 Mar 06 |
jari |
54 |
{ |
80 |
10 Mar 06 |
jari |
55 |
} |
80 |
10 Mar 06 |
jari |
56 |
|
529 |
25 Dec 07 |
peter |
57 |
|
528 |
25 Dec 07 |
peter |
58 |
ClassicStats::ClassicStats(const ClassicStats& other) |
528 |
25 Dec 07 |
peter |
59 |
: Stats(other) |
528 |
25 Dec 07 |
peter |
60 |
{ |
528 |
25 Dec 07 |
peter |
61 |
} |
80 |
10 Mar 06 |
jari |
62 |
|
14 |
30 Dec 05 |
peter |
63 |
|
664 |
13 Jun 08 |
peter |
64 |
void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev) |
60 |
16 Jan 06 |
peter |
65 |
{ |
1478 |
29 May 12 |
peter |
66 |
svn_revnum_t first_rev = ignore_rev() + 1; |
803 |
10 Jul 09 |
peter |
67 |
reset(); |
552 |
08 Jan 08 |
peter |
68 |
LineTypeParser parser(path); |
185 |
06 Sep 06 |
jari |
69 |
SVNblame svn_blame(path); |
1611 |
12 Feb 23 |
peter |
70 |
std::vector<std::map<std::string, SparseVector> > data(5); |
381 |
21 Jun 07 |
jari |
71 |
while (svn_blame.valid()) { |
1194 |
03 Oct 10 |
peter |
72 |
LineTypeParser::line_type lt = parser.parse(svn_blame.line()); |
1611 |
12 Feb 23 |
peter |
73 |
if (lt == LineTypeParser::copyright || lt == LineTypeParser::comment) |
1611 |
12 Feb 23 |
peter |
74 |
lt = LineTypeParser::comment_or_copy; |
1418 |
25 Oct 11 |
peter |
75 |
assert(static_cast<size_t>(lt)<data.size()); |
1478 |
29 May 12 |
peter |
76 |
if (svn_blame.revision()>=first_rev) { |
1478 |
29 May 12 |
peter |
77 |
SparseVector& vec = data[lt][svn_blame.author()]; |
1478 |
29 May 12 |
peter |
78 |
vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1); |
1478 |
29 May 12 |
peter |
79 |
} |
381 |
21 Jun 07 |
jari |
80 |
svn_blame.next_line(); |
138 |
03 Aug 06 |
jari |
81 |
} |
1194 |
03 Oct 10 |
peter |
// add parsed data to member |
1194 |
03 Oct 10 |
peter |
83 |
add(data); |
60 |
16 Jan 06 |
peter |
84 |
} |
60 |
16 Jan 06 |
peter |
85 |
|
60 |
16 Jan 06 |
peter |
86 |
|
1513 |
23 Sep 12 |
peter |
87 |
unsigned int |
1513 |
23 Sep 12 |
peter |
88 |
ClassicStats::max_element(const SumVector& v) const |
1036 |
15 Feb 10 |
peter |
89 |
{ |
1280 |
06 Nov 10 |
peter |
90 |
if (v.size()==0) |
1280 |
06 Nov 10 |
peter |
91 |
return 0; |
1036 |
15 Feb 10 |
peter |
92 |
return v.back(); |
1036 |
15 Feb 10 |
peter |
93 |
} |
1036 |
15 Feb 10 |
peter |
94 |
|
149 |
12 Aug 06 |
jari |
95 |
}} // end of namespace svndigest and namespace theplu |