165 |
24 Aug 06 |
jari |
1 |
#ifndef _theplu_svndigest_svnblame_ |
165 |
24 Aug 06 |
jari |
2 |
#define _theplu_svndigest_svnblame_ |
165 |
24 Aug 06 |
jari |
3 |
|
138 |
03 Aug 06 |
jari |
// $Id$ |
138 |
03 Aug 06 |
jari |
5 |
|
138 |
03 Aug 06 |
jari |
6 |
/* |
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 |
138 |
03 Aug 06 |
jari |
9 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
138 |
03 Aug 06 |
jari |
11 |
|
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 |
16 |
|
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 |
21 |
|
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 |
24 |
*/ |
138 |
03 Aug 06 |
jari |
25 |
|
138 |
03 Aug 06 |
jari |
26 |
#include <string> |
138 |
03 Aug 06 |
jari |
27 |
#include <vector> |
138 |
03 Aug 06 |
jari |
28 |
|
164 |
23 Aug 06 |
jari |
29 |
#include <subversion-1/svn_client.h> |
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 |
class SVN; |
138 |
03 Aug 06 |
jari |
35 |
|
381 |
21 Jun 07 |
jari |
36 |
/** |
381 |
21 Jun 07 |
jari |
The SVNblame class is a utility class for taking care of 'svn |
381 |
21 Jun 07 |
jari |
blame' information. An 'svn blame' is performed on an item, the |
381 |
21 Jun 07 |
jari |
blame information for each line is traversed with |
381 |
21 Jun 07 |
jari |
SVNblame.next_line() and SVNblame.valid() calls giving access to |
381 |
21 Jun 07 |
jari |
the blame information. |
381 |
21 Jun 07 |
jari |
42 |
*/ |
138 |
03 Aug 06 |
jari |
43 |
class SVNblame { |
138 |
03 Aug 06 |
jari |
44 |
public: |
138 |
03 Aug 06 |
jari |
45 |
|
381 |
21 Jun 07 |
jari |
46 |
/** |
381 |
21 Jun 07 |
jari |
@brief The contructor. |
138 |
03 Aug 06 |
jari |
48 |
|
381 |
21 Jun 07 |
jari |
The constructor performs an 'svn blame' on \a path and |
381 |
21 Jun 07 |
jari |
initializes the SVNblame object for statistics traversal using |
381 |
21 Jun 07 |
jari |
SVNblame::next_line() and SVNblame::valid(). |
381 |
21 Jun 07 |
jari |
52 |
*/ |
138 |
03 Aug 06 |
jari |
53 |
explicit SVNblame(const std::string& path); |
138 |
03 Aug 06 |
jari |
54 |
|
381 |
21 Jun 07 |
jari |
55 |
/** |
501 |
19 Oct 07 |
peter |
@brief The contructor. |
501 |
19 Oct 07 |
peter |
57 |
|
501 |
19 Oct 07 |
peter |
The constructor performs an 'svn blame -r rev' on \a path and |
501 |
19 Oct 07 |
peter |
initializes the SVNblame object for statistics traversal using |
501 |
19 Oct 07 |
peter |
SVNblame::next_line() and SVNblame::valid(). |
501 |
19 Oct 07 |
peter |
61 |
*/ |
501 |
19 Oct 07 |
peter |
62 |
SVNblame(const std::string& path, svn_revnum_t rev); |
501 |
19 Oct 07 |
peter |
63 |
|
501 |
19 Oct 07 |
peter |
64 |
/** |
381 |
21 Jun 07 |
jari |
@brief The destructor. |
381 |
21 Jun 07 |
jari |
66 |
*/ |
138 |
03 Aug 06 |
jari |
67 |
~SVNblame(void); |
138 |
03 Aug 06 |
jari |
68 |
|
381 |
21 Jun 07 |
jari |
69 |
/** |
395 |
26 Jun 07 |
peter |
@brief Retrieve the author for the current line. |
138 |
03 Aug 06 |
jari |
71 |
|
381 |
21 Jun 07 |
jari |
If current line is outside blame entries the behaviour is |
381 |
21 Jun 07 |
jari |
undefined. |
381 |
21 Jun 07 |
jari |
74 |
|
395 |
26 Jun 07 |
peter |
@return The author. |
381 |
21 Jun 07 |
jari |
76 |
*/ |
381 |
21 Jun 07 |
jari |
77 |
std::string author(void); |
381 |
21 Jun 07 |
jari |
78 |
|
205 |
10 Sep 06 |
jari |
79 |
/** |
381 |
21 Jun 07 |
jari |
@brief Retrieve the blame date for the current line. |
381 |
21 Jun 07 |
jari |
81 |
|
381 |
21 Jun 07 |
jari |
If current line is outside blame entries the behaviour is |
381 |
21 Jun 07 |
jari |
undefined. |
381 |
21 Jun 07 |
jari |
84 |
|
381 |
21 Jun 07 |
jari |
@return The date. |
205 |
10 Sep 06 |
jari |
86 |
*/ |
381 |
21 Jun 07 |
jari |
87 |
std::string date(void); |
138 |
03 Aug 06 |
jari |
88 |
|
381 |
21 Jun 07 |
jari |
89 |
/** |
381 |
21 Jun 07 |
jari |
@brief Retrieve the content of the current line. |
381 |
21 Jun 07 |
jari |
91 |
|
381 |
21 Jun 07 |
jari |
If current line is outside blame entries the behaviour is |
381 |
21 Jun 07 |
jari |
undefined. |
381 |
21 Jun 07 |
jari |
94 |
|
381 |
21 Jun 07 |
jari |
@return The line content. |
381 |
21 Jun 07 |
jari |
96 |
*/ |
381 |
21 Jun 07 |
jari |
97 |
std::string line(void); |
381 |
21 Jun 07 |
jari |
98 |
|
381 |
21 Jun 07 |
jari |
99 |
/** |
381 |
21 Jun 07 |
jari |
@brief Retrieve the line number of the current line. |
381 |
21 Jun 07 |
jari |
101 |
|
381 |
21 Jun 07 |
jari |
If current line is outside blame entries the behaviour is |
381 |
21 Jun 07 |
jari |
undefined. |
381 |
21 Jun 07 |
jari |
104 |
|
381 |
21 Jun 07 |
jari |
@return The line number. |
381 |
21 Jun 07 |
jari |
106 |
*/ |
381 |
21 Jun 07 |
jari |
107 |
apr_int64_t line_no(void); |
381 |
21 Jun 07 |
jari |
108 |
|
381 |
21 Jun 07 |
jari |
109 |
/** |
381 |
21 Jun 07 |
jari |
@brief Skip to the next line. |
381 |
21 Jun 07 |
jari |
111 |
|
381 |
21 Jun 07 |
jari |
@return False if no more blame information is available, true |
381 |
21 Jun 07 |
jari |
otherwise. |
381 |
21 Jun 07 |
jari |
114 |
*/ |
381 |
21 Jun 07 |
jari |
115 |
bool next_line(void); |
381 |
21 Jun 07 |
jari |
116 |
|
381 |
21 Jun 07 |
jari |
117 |
/** |
381 |
21 Jun 07 |
jari |
@brief Retrieve the blame revision of the current line. |
381 |
21 Jun 07 |
jari |
119 |
|
381 |
21 Jun 07 |
jari |
If current line is outside blame entries the behaviour is |
381 |
21 Jun 07 |
jari |
undefined. |
381 |
21 Jun 07 |
jari |
122 |
|
381 |
21 Jun 07 |
jari |
@return The blame revision. |
381 |
21 Jun 07 |
jari |
124 |
*/ |
381 |
21 Jun 07 |
jari |
125 |
svn_revnum_t revision(void); |
381 |
21 Jun 07 |
jari |
126 |
|
381 |
21 Jun 07 |
jari |
127 |
/** |
535 |
27 Dec 07 |
peter |
\brief resets iterator to first line |
535 |
27 Dec 07 |
peter |
129 |
*/ |
535 |
27 Dec 07 |
peter |
130 |
void reset(void); |
535 |
27 Dec 07 |
peter |
131 |
|
535 |
27 Dec 07 |
peter |
132 |
/** |
381 |
21 Jun 07 |
jari |
@brief Check if more blame information is available. |
381 |
21 Jun 07 |
jari |
134 |
|
381 |
21 Jun 07 |
jari |
@return True if valid information exists, false otherwise. |
381 |
21 Jun 07 |
jari |
136 |
*/ |
381 |
21 Jun 07 |
jari |
137 |
bool valid(void); |
381 |
21 Jun 07 |
jari |
138 |
|
138 |
03 Aug 06 |
jari |
139 |
private: |
138 |
03 Aug 06 |
jari |
140 |
|
381 |
21 Jun 07 |
jari |
141 |
/** |
381 |
21 Jun 07 |
jari |
@brief Copy Constructor, not implemented. |
381 |
21 Jun 07 |
jari |
143 |
*/ |
138 |
03 Aug 06 |
jari |
144 |
SVNblame(const SVNblame&); |
138 |
03 Aug 06 |
jari |
145 |
|
381 |
21 Jun 07 |
jari |
146 |
/** |
381 |
21 Jun 07 |
jari |
@brief Information return by subversion (blame) API |
381 |
21 Jun 07 |
jari |
148 |
|
381 |
21 Jun 07 |
jari |
@see Subversion API for blame usage. |
381 |
21 Jun 07 |
jari |
150 |
*/ |
381 |
21 Jun 07 |
jari |
151 |
struct blame_information { |
381 |
21 Jun 07 |
jari |
152 |
apr_int64_t line_no; |
381 |
21 Jun 07 |
jari |
153 |
svn_revnum_t revision; |
381 |
21 Jun 07 |
jari |
154 |
std::string author; |
381 |
21 Jun 07 |
jari |
155 |
std::string date; |
381 |
21 Jun 07 |
jari |
156 |
std::string line; |
381 |
21 Jun 07 |
jari |
157 |
}; |
381 |
21 Jun 07 |
jari |
158 |
|
138 |
03 Aug 06 |
jari |
// blame_info_iterator_ is used in statistics analysis to traverse |
138 |
03 Aug 06 |
jari |
// blame_receiver_baton.blame_info vector through calls to next(). |
138 |
03 Aug 06 |
jari |
161 |
std::vector<blame_information*>::iterator blame_info_iterator_; |
138 |
03 Aug 06 |
jari |
162 |
SVN* instance_; |
138 |
03 Aug 06 |
jari |
163 |
|
138 |
03 Aug 06 |
jari |
164 |
struct blame_receiver_baton_ { |
138 |
03 Aug 06 |
jari |
165 |
std::vector<blame_information*> blame_info; |
138 |
03 Aug 06 |
jari |
166 |
} blame_receiver_baton_ ; |
138 |
03 Aug 06 |
jari |
167 |
|
138 |
03 Aug 06 |
jari |
168 |
static svn_error_t * |
138 |
03 Aug 06 |
jari |
169 |
blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision, |
138 |
03 Aug 06 |
jari |
170 |
const char *author, const char *date, const char *line, |
138 |
03 Aug 06 |
jari |
171 |
apr_pool_t *pool); |
138 |
03 Aug 06 |
jari |
172 |
}; |
138 |
03 Aug 06 |
jari |
173 |
|
149 |
12 Aug 06 |
jari |
174 |
}} // end of namespace svndigest and namespace theplu |
138 |
03 Aug 06 |
jari |
175 |
|
138 |
03 Aug 06 |
jari |
176 |
#endif |