138 |
03 Aug 06 |
jari |
// $Id$ |
138 |
03 Aug 06 |
jari |
2 |
|
138 |
03 Aug 06 |
jari |
3 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen |
978 |
12 Dec 09 |
peter |
Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2023 Peter Johansson |
138 |
03 Aug 06 |
jari |
7 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
138 |
03 Aug 06 |
jari |
9 |
|
149 |
12 Aug 06 |
jari |
svndigest is free software; you can redistribute it and/or modify it |
138 |
03 Aug 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 |
138 |
03 Aug 06 |
jari |
(at your option) any later version. |
138 |
03 Aug 06 |
jari |
14 |
|
149 |
12 Aug 06 |
jari |
svndigest is distributed in the hope that it will be useful, but |
138 |
03 Aug 06 |
jari |
WITHOUT ANY WARRANTY; without even the implied warranty of |
138 |
03 Aug 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
138 |
03 Aug 06 |
jari |
General Public License for more details. |
138 |
03 Aug 06 |
jari |
19 |
|
138 |
03 Aug 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/>. |
138 |
03 Aug 06 |
jari |
22 |
*/ |
138 |
03 Aug 06 |
jari |
23 |
|
1619 |
12 Mar 23 |
peter |
24 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
25 |
|
138 |
03 Aug 06 |
jari |
26 |
#include "SVNblame.h" |
138 |
03 Aug 06 |
jari |
27 |
#include "SVN.h" |
138 |
03 Aug 06 |
jari |
28 |
|
138 |
03 Aug 06 |
jari |
29 |
#include <string> |
138 |
03 Aug 06 |
jari |
30 |
|
138 |
03 Aug 06 |
jari |
31 |
namespace theplu { |
149 |
12 Aug 06 |
jari |
32 |
namespace svndigest { |
138 |
03 Aug 06 |
jari |
33 |
|
138 |
03 Aug 06 |
jari |
34 |
|
138 |
03 Aug 06 |
jari |
35 |
SVNblame::SVNblame(const std::string& path) |
1218 |
10 Oct 10 |
peter |
36 |
: instance_(SVN::instance()) |
138 |
03 Aug 06 |
jari |
37 |
{ |
1218 |
10 Oct 10 |
peter |
38 |
instance_->client_blame(path.c_str(), blame_receiver, |
1218 |
10 Oct 10 |
peter |
39 |
static_cast<void*>(&blame_receiver_baton_)); |
138 |
03 Aug 06 |
jari |
40 |
blame_info_iterator_ = blame_receiver_baton_.blame_info.begin(); |
138 |
03 Aug 06 |
jari |
41 |
} |
138 |
03 Aug 06 |
jari |
42 |
|
138 |
03 Aug 06 |
jari |
43 |
|
501 |
19 Oct 07 |
peter |
44 |
SVNblame::SVNblame(const std::string& path, svn_revnum_t rev) |
1218 |
10 Oct 10 |
peter |
45 |
: instance_(SVN::instance()) |
501 |
19 Oct 07 |
peter |
46 |
{ |
1218 |
10 Oct 10 |
peter |
47 |
instance_->client_blame(path.c_str(), blame_receiver, |
1218 |
10 Oct 10 |
peter |
48 |
static_cast<void*>(&blame_receiver_baton_), |
1218 |
10 Oct 10 |
peter |
49 |
rev); |
501 |
19 Oct 07 |
peter |
50 |
blame_info_iterator_ = blame_receiver_baton_.blame_info.begin(); |
501 |
19 Oct 07 |
peter |
51 |
} |
501 |
19 Oct 07 |
peter |
52 |
|
501 |
19 Oct 07 |
peter |
53 |
|
138 |
03 Aug 06 |
jari |
54 |
SVNblame::~SVNblame(void) |
138 |
03 Aug 06 |
jari |
55 |
{ |
138 |
03 Aug 06 |
jari |
56 |
std::vector<blame_information*>::iterator i= |
138 |
03 Aug 06 |
jari |
57 |
blame_receiver_baton_.blame_info.begin(); |
138 |
03 Aug 06 |
jari |
58 |
while (i!=blame_receiver_baton_.blame_info.end()) { |
138 |
03 Aug 06 |
jari |
59 |
delete *i; |
138 |
03 Aug 06 |
jari |
60 |
++i; |
138 |
03 Aug 06 |
jari |
61 |
} |
138 |
03 Aug 06 |
jari |
62 |
} |
138 |
03 Aug 06 |
jari |
63 |
|
138 |
03 Aug 06 |
jari |
64 |
|
381 |
21 Jun 07 |
jari |
65 |
std::string SVNblame::author(void) |
138 |
03 Aug 06 |
jari |
66 |
{ |
381 |
21 Jun 07 |
jari |
67 |
return (*blame_info_iterator_)->author; |
138 |
03 Aug 06 |
jari |
68 |
} |
138 |
03 Aug 06 |
jari |
69 |
|
138 |
03 Aug 06 |
jari |
70 |
|
138 |
03 Aug 06 |
jari |
71 |
svn_error_t * |
138 |
03 Aug 06 |
jari |
72 |
SVNblame::blame_receiver(void *baton, apr_int64_t line_no, |
138 |
03 Aug 06 |
jari |
73 |
svn_revnum_t revision, const char *author, |
138 |
03 Aug 06 |
jari |
74 |
const char *date, const char *line, apr_pool_t *pool) |
138 |
03 Aug 06 |
jari |
75 |
{ |
138 |
03 Aug 06 |
jari |
76 |
blame_information *bi=new blame_information; |
138 |
03 Aug 06 |
jari |
77 |
bi->line_no=line_no; |
138 |
03 Aug 06 |
jari |
78 |
bi->revision=revision; |
138 |
03 Aug 06 |
jari |
79 |
bi->author=author; |
138 |
03 Aug 06 |
jari |
80 |
bi->date=date; |
138 |
03 Aug 06 |
jari |
81 |
bi->line=line; |
138 |
03 Aug 06 |
jari |
82 |
static_cast<struct blame_receiver_baton_*>(baton)->blame_info.push_back(bi); |
138 |
03 Aug 06 |
jari |
83 |
return SVN_NO_ERROR; |
138 |
03 Aug 06 |
jari |
84 |
} |
138 |
03 Aug 06 |
jari |
85 |
|
138 |
03 Aug 06 |
jari |
86 |
|
381 |
21 Jun 07 |
jari |
87 |
std::string SVNblame::date(void) |
381 |
21 Jun 07 |
jari |
88 |
{ |
381 |
21 Jun 07 |
jari |
89 |
return (*blame_info_iterator_)->date; |
381 |
21 Jun 07 |
jari |
90 |
} |
381 |
21 Jun 07 |
jari |
91 |
|
381 |
21 Jun 07 |
jari |
92 |
|
381 |
21 Jun 07 |
jari |
93 |
std::string SVNblame::line(void) |
381 |
21 Jun 07 |
jari |
94 |
{ |
381 |
21 Jun 07 |
jari |
95 |
return (*blame_info_iterator_)->line; |
381 |
21 Jun 07 |
jari |
96 |
} |
381 |
21 Jun 07 |
jari |
97 |
|
381 |
21 Jun 07 |
jari |
98 |
|
381 |
21 Jun 07 |
jari |
99 |
apr_int64_t SVNblame::line_no(void) |
381 |
21 Jun 07 |
jari |
100 |
{ |
381 |
21 Jun 07 |
jari |
101 |
return (*blame_info_iterator_)->line_no; |
381 |
21 Jun 07 |
jari |
102 |
} |
381 |
21 Jun 07 |
jari |
103 |
|
381 |
21 Jun 07 |
jari |
104 |
|
381 |
21 Jun 07 |
jari |
105 |
bool SVNblame::next_line(void) |
381 |
21 Jun 07 |
jari |
106 |
{ |
381 |
21 Jun 07 |
jari |
107 |
if (valid()) |
381 |
21 Jun 07 |
jari |
108 |
++blame_info_iterator_; |
381 |
21 Jun 07 |
jari |
109 |
return valid(); |
381 |
21 Jun 07 |
jari |
110 |
} |
381 |
21 Jun 07 |
jari |
111 |
|
381 |
21 Jun 07 |
jari |
112 |
|
381 |
21 Jun 07 |
jari |
113 |
svn_revnum_t SVNblame::revision(void) |
381 |
21 Jun 07 |
jari |
114 |
{ |
381 |
21 Jun 07 |
jari |
115 |
return (*blame_info_iterator_)->revision; |
381 |
21 Jun 07 |
jari |
116 |
} |
381 |
21 Jun 07 |
jari |
117 |
|
381 |
21 Jun 07 |
jari |
118 |
|
535 |
27 Dec 07 |
peter |
119 |
void SVNblame::reset(void) |
535 |
27 Dec 07 |
peter |
120 |
{ |
535 |
27 Dec 07 |
peter |
121 |
blame_info_iterator_ = blame_receiver_baton_.blame_info.begin(); |
535 |
27 Dec 07 |
peter |
122 |
} |
535 |
27 Dec 07 |
peter |
123 |
|
535 |
27 Dec 07 |
peter |
124 |
|
381 |
21 Jun 07 |
jari |
125 |
bool SVNblame::valid(void) |
381 |
21 Jun 07 |
jari |
126 |
{ |
381 |
21 Jun 07 |
jari |
127 |
return (blame_info_iterator_!=blame_receiver_baton_.blame_info.end()); |
381 |
21 Jun 07 |
jari |
128 |
} |
381 |
21 Jun 07 |
jari |
129 |
|
149 |
12 Aug 06 |
jari |
130 |
}} // end of namespace svndigest and namespace theplu |