source: trunk/lib/SVNblame.h @ 791

Last change on this file since 791 was 768, checked in by Peter Johansson, 12 years ago

Merged patch release 0.6.7 to trunk. Delta 0.6.7 - 0.6.6

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1#ifndef _theplu_svndigest_svnblame_
2#define _theplu_svndigest_svnblame_
3
4// $Id: SVNblame.h 768 2009-01-31 21:30:37Z peter $
5
6/*
7  Copyright (C) 2006 Jari Häkkinen
8  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2008 Peter Johansson
10
11  This file is part of svndigest, http://dev.thep.lu.se/svndigest
12
13  svndigest is free software; you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation; either version 3 of the License, or
16  (at your option) any later version.
17
18  svndigest is distributed in the hope that it will be useful, but
19  WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  General Public License for more details.
22
23  You should have received a copy of the GNU General Public License
24  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
25*/
26
27#include <string>
28#include <vector>
29
30#include <subversion-1/svn_client.h>
31
32namespace theplu {
33namespace svndigest {
34
35  class SVN;
36
37  /**
38     The SVNblame class is a utility class for taking care of 'svn
39     blame' information. An 'svn blame' is performed on an item, the
40     blame information for each line is traversed with
41     SVNblame.next_line() and SVNblame.valid() calls giving access to
42     the blame information.
43  */
44  class SVNblame {
45  public:
46
47    /**
48       @brief The contructor.
49
50       The constructor performs an 'svn blame' on \a path and
51       initializes the SVNblame object for statistics traversal using
52       SVNblame::next_line() and SVNblame::valid().
53    */
54    explicit SVNblame(const std::string& path);
55
56    /**
57       @brief The contructor.
58
59       The constructor performs an 'svn blame -r rev' on \a path and
60       initializes the SVNblame object for statistics traversal using
61       SVNblame::next_line() and SVNblame::valid().
62    */
63    SVNblame(const std::string& path, svn_revnum_t rev);
64
65    /**
66       @brief The destructor.
67    */
68    ~SVNblame(void);
69
70    /**
71       @brief Retrieve the author for the current line.
72
73       If current line is outside blame entries the behaviour is
74       undefined.
75
76       @return The author.
77    */
78    std::string author(void);
79
80    /**
81       Returns true if item is binary false otherwise
82
83       Binary files are invalid for 'svn blame'.
84    */
85    bool binary(void);
86
87    /**
88       @brief Retrieve the blame date for the current line.
89
90       If current line is outside blame entries the behaviour is
91       undefined.
92
93       @return The date.
94    */
95    std::string date(void);
96
97    /**
98       @brief Retrieve the content of the current line.
99
100       If current line is outside blame entries the behaviour is
101       undefined.
102
103       @return The line content.
104    */
105    std::string line(void);
106
107    /**
108       @brief Retrieve the line number of the current line.
109
110       If current line is outside blame entries the behaviour is
111       undefined.
112
113       @return The line number.
114    */
115    apr_int64_t line_no(void);
116
117    /**
118       @brief Skip to the next line.
119
120       @return False if no more blame information is available, true
121       otherwise.
122    */
123    bool next_line(void);
124
125    /**
126       @brief Retrieve the blame revision of the current line.
127
128       If current line is outside blame entries the behaviour is
129       undefined.
130
131       @return The blame revision.
132    */
133    svn_revnum_t revision(void);
134
135    /**
136       \brief resets iterator to first line
137     */
138    void reset(void);
139
140    /**
141       @brief Check if more blame information is available.
142
143       @return True if valid information exists, false otherwise.
144    */
145    bool valid(void);
146
147  private:
148
149    /**
150       @brief Copy Constructor, not implemented.
151    */
152    SVNblame(const SVNblame&);
153
154    /**
155       @brief Information return by subversion (blame) API
156
157       @see Subversion API for blame usage.
158    */
159    struct blame_information {
160      apr_int64_t line_no;
161      svn_revnum_t revision;
162      std::string author;
163      std::string date;
164      std::string line;
165    };
166
167    // binary_ is true if item in any revision has been binary.
168    bool binary_;
169    // blame_info_iterator_ is used in statistics analysis to traverse
170    // blame_receiver_baton.blame_info vector through calls to next().
171    std::vector<blame_information*>::iterator blame_info_iterator_;
172    SVN* instance_;
173
174    struct blame_receiver_baton_ {
175      std::vector<blame_information*> blame_info;
176    } blame_receiver_baton_ ;
177
178    static svn_error_t *
179    blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision,
180                   const char *author, const char *date, const char *line,
181                   apr_pool_t *pool);
182  };
183
184}} // end of namespace svndigest and namespace theplu
185
186#endif
Note: See TracBrowser for help on using the repository browser.