source: tags/0.6/lib/SVNblame.h @ 416

Last change on this file since 416 was 408, checked in by Jari Häkkinen, 14 years ago

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