1 | #ifndef _theplu_svndigest_svnlog_ |
---|
2 | #define _theplu_svndigest_svnlog_ |
---|
3 | |
---|
4 | // $Id: SVNlog.h 519 2007-12-23 20:14:50Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
8 | |
---|
9 | This file is part of svndigest, http://trac.thep.lu.se/svndigest |
---|
10 | |
---|
11 | svndigest is free software; you can redistribute it and/or modify it |
---|
12 | under the terms of the GNU General Public License as published by |
---|
13 | the Free Software Foundation; either version 2 of the License, or |
---|
14 | (at your option) any later version. |
---|
15 | |
---|
16 | svndigest is distributed in the hope that it will be useful, but |
---|
17 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
19 | General Public License for more details. |
---|
20 | |
---|
21 | You should have received a copy of the GNU General Public License |
---|
22 | along with this program; if not, write to the Free Software |
---|
23 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
24 | 02111-1307, USA. |
---|
25 | */ |
---|
26 | |
---|
27 | #include "SVN.h" |
---|
28 | |
---|
29 | #include "Commitment.h" |
---|
30 | #include "LogIterator.h" |
---|
31 | |
---|
32 | #include <string> |
---|
33 | #include <vector> |
---|
34 | |
---|
35 | #include <subversion-1/svn_client.h> |
---|
36 | |
---|
37 | namespace theplu { |
---|
38 | namespace svndigest { |
---|
39 | |
---|
40 | class SVN; |
---|
41 | |
---|
42 | /** |
---|
43 | The SVNlog class is a utility class for taking care of 'svn |
---|
44 | log' information. An 'svn log' is performed on an item, the |
---|
45 | log information for each revision is stored in vectors. |
---|
46 | */ |
---|
47 | class SVNlog { |
---|
48 | public: |
---|
49 | |
---|
50 | /** |
---|
51 | Default constructor. Creates empty log. |
---|
52 | */ |
---|
53 | SVNlog(void); |
---|
54 | |
---|
55 | /** |
---|
56 | \brief The contructor. |
---|
57 | |
---|
58 | The constructor performs an 'svn log' on \a path and |
---|
59 | stores the information for later access. |
---|
60 | */ |
---|
61 | explicit SVNlog(const std::string& path); |
---|
62 | |
---|
63 | /** |
---|
64 | \brief The destructor. |
---|
65 | */ |
---|
66 | ~SVNlog(void); |
---|
67 | |
---|
68 | /** |
---|
69 | \return Authors |
---|
70 | */ |
---|
71 | inline const std::vector<std::string>& author(void) const |
---|
72 | { return lb_.authors; } |
---|
73 | |
---|
74 | /** |
---|
75 | */ |
---|
76 | LogIterator begin(void) const; |
---|
77 | |
---|
78 | /** |
---|
79 | \return Dates |
---|
80 | */ |
---|
81 | inline const std::vector<std::string>& date(void) const |
---|
82 | { return lb_.commit_dates; } |
---|
83 | |
---|
84 | /** |
---|
85 | */ |
---|
86 | LogIterator end(void) const; |
---|
87 | |
---|
88 | /** |
---|
89 | \return true if \a author appears in log. |
---|
90 | */ |
---|
91 | bool exist(std::string author) const; |
---|
92 | |
---|
93 | /** |
---|
94 | \return Messages |
---|
95 | */ |
---|
96 | inline const std::vector<std::string>& message(void) const |
---|
97 | { return lb_.msg; } |
---|
98 | |
---|
99 | /** |
---|
100 | \return Latest commit |
---|
101 | */ |
---|
102 | Commitment latest_commit(void) const; |
---|
103 | |
---|
104 | /** |
---|
105 | \return Latest commit \a author did. If no author is found an |
---|
106 | empty Commitment (default constructor) is returned. |
---|
107 | */ |
---|
108 | Commitment latest_commit(std::string author) const; |
---|
109 | |
---|
110 | /** |
---|
111 | \return Revisions |
---|
112 | */ |
---|
113 | inline const std::vector<size_t>& revision(void) const |
---|
114 | { return lb_.rev; } |
---|
115 | |
---|
116 | /** |
---|
117 | */ |
---|
118 | void push_back(const Commitment&); |
---|
119 | |
---|
120 | /** |
---|
121 | */ |
---|
122 | void reserve(size_t i); |
---|
123 | |
---|
124 | /** |
---|
125 | */ |
---|
126 | void swap(SVNlog&); |
---|
127 | |
---|
128 | private: |
---|
129 | |
---|
130 | /// |
---|
131 | /// @brief Copy Constructor, not implemented. |
---|
132 | /// |
---|
133 | // using compiler generated copy constructor |
---|
134 | //SVNlog(const SVNlog&); |
---|
135 | |
---|
136 | /** |
---|
137 | log information is stored in the log_receiver_baton. The |
---|
138 | information is retrieved with the info_* set of member |
---|
139 | functions. The struct is filled in the info_receiver function. |
---|
140 | |
---|
141 | \see info_receiver |
---|
142 | */ |
---|
143 | struct log_receiver_baton { |
---|
144 | std::vector<std::string> authors; |
---|
145 | std::vector<std::string> commit_dates; |
---|
146 | std::vector<std::string> msg; |
---|
147 | std::vector<size_t> rev; |
---|
148 | } lb_; |
---|
149 | |
---|
150 | /** |
---|
151 | info_receiver is the function passed to the underlying |
---|
152 | subversion API. This function is called by the subversion API |
---|
153 | for every item matched by the conditions of the API call. |
---|
154 | |
---|
155 | \see Subversion API documentation |
---|
156 | */ |
---|
157 | // The return type should be svn_log_message_receiver_t but I |
---|
158 | // cannot get it to compile. The svn API has a typedef like |
---|
159 | // typedef svn_error_t*(* svn_log_message_receiver_t)(void *baton, |
---|
160 | // apr_hash_t *changed_paths, svn_revnum_t revision, const char |
---|
161 | // *author, const char *date,const char *message, apr_pool_t |
---|
162 | // *pool) for svn_log_message_receiver_t. |
---|
163 | static svn_error_t* |
---|
164 | log_message_receiver(void *baton, apr_hash_t *changed_paths, |
---|
165 | svn_revnum_t rev, const char *author, const char *date, |
---|
166 | const char *msg, apr_pool_t *pool); |
---|
167 | }; |
---|
168 | |
---|
169 | /** |
---|
170 | */ |
---|
171 | SVNlog& operator+=(SVNlog&, const SVNlog&); |
---|
172 | |
---|
173 | }} // end of namespace svndigest and namespace theplu |
---|
174 | |
---|
175 | #endif |
---|