source: branches/0.6-stable/lib/SVNblame.h

Last change on this file was 731, checked in by Peter Johansson, 13 years ago

update copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1#ifndef _theplu_svndigest_svnblame_
2#define _theplu_svndigest_svnblame_
3
4// $Id: SVNblame.h 731 2008-12-15 19:03:04Z 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 2 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 this program; if not, write to the Free Software
25  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26  02111-1307, USA.
27*/
28
29#include <string>
30#include <vector>
31
32#include <subversion-1/svn_client.h>
33
34namespace theplu {
35namespace svndigest {
36
37  class SVN;
38
39  /**
40     The SVNblame class is a utility class for taking care of 'svn
41     blame' information. An 'svn blame' is performed on an item, the
42     blame information for each line is traversed with
43     SVNblame.next_line() and SVNblame.valid() calls giving access to
44     the blame information.
45  */
46  class SVNblame {
47  public:
48
49    /**
50       @brief The contructor.
51
52       The constructor performs an 'svn blame' on \a path and
53       initializes the SVNblame object for statistics traversal using
54       SVNblame::next_line() and SVNblame::valid().
55    */
56    explicit SVNblame(const std::string& path);
57
58    /**
59       @brief The destructor.
60    */
61    ~SVNblame(void);
62
63    /**
64       @brief Retrieve the author for the current line.
65
66       If current line is outside blame entries the behaviour is
67       undefined.
68
69       @return The author.
70    */
71    std::string author(void);
72
73    /**
74       Returns true if item is binary false otherwise
75
76       Binary files are invalid for 'svn blame'.
77    */
78    bool binary(void);
79
80    /**
81       @brief Retrieve the blame date for the current line.
82
83       If current line is outside blame entries the behaviour is
84       undefined.
85
86       @return The date.
87    */
88    std::string date(void);
89
90    /**
91       @brief Retrieve the content of the current line.
92
93       If current line is outside blame entries the behaviour is
94       undefined.
95
96       @return The line content.
97    */
98    std::string line(void);
99
100    /**
101       @brief Retrieve the line number of the current line.
102
103       If current line is outside blame entries the behaviour is
104       undefined.
105
106       @return The line number.
107    */
108    apr_int64_t line_no(void);
109
110    /**
111       @brief Skip to the next line.
112
113       @return False if no more blame information is available, true
114       otherwise.
115    */
116    bool next_line(void);
117
118    /**
119       @brief Retrieve the blame revision of the current line.
120
121       If current line is outside blame entries the behaviour is
122       undefined.
123
124       @return The blame revision.
125    */
126    svn_revnum_t revision(void);
127
128    /**
129       @brief Check if more blame information is available.
130
131       @return True if valid information exists, false otherwise.
132    */
133    bool valid(void);
134
135  private:
136
137    /**
138       @brief Copy Constructor, not implemented.
139    */
140    SVNblame(const SVNblame&);
141
142    /**
143       @brief Information return by subversion (blame) API
144
145       @see Subversion API for blame usage.
146    */
147    struct blame_information {
148      apr_int64_t line_no;
149      svn_revnum_t revision;
150      std::string author;
151      std::string date;
152      std::string line;
153    };
154
155    // binary_ is true if item in any revision has been binary.
156    bool binary_;
157    // blame_info_iterator_ is used in statistics analysis to traverse
158    // blame_receiver_baton.blame_info vector through calls to next().
159    std::vector<blame_information*>::iterator blame_info_iterator_;
160    SVN* instance_;
161
162    struct blame_receiver_baton_ {
163      std::vector<blame_information*> blame_info;
164    } blame_receiver_baton_ ;
165
166    static svn_error_t *
167    blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision,
168                   const char *author, const char *date, const char *line,
169                   apr_pool_t *pool);
170  };
171
172}} // end of namespace svndigest and namespace theplu
173
174#endif
Note: See TracBrowser for help on using the repository browser.