source: trunk/lib/SVNblame.h @ 381

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

SVNblame redesigned.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1#ifndef _theplu_svndigest_svnblame_
2#define _theplu_svndigest_svnblame_
3
4// $Id: SVNblame.h 381 2007-06-21 20:43:17Z jari $
5
6/*
7  Copyright (C) 2006, 2007 Jari Häkkinen
8
9  This file is part of svndigest, http://lev.thep.lu.se/trac/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 <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 destructor.
58    */
59    ~SVNblame(void);
60
61    /**
62       @brief Retrieve the blame date for the current line.
63
64       If current line is outside blame entries the behaviour is
65       undefined.
66
67       @return The date.
68    */
69    std::string author(void);
70
71    /**
72       Returns true if item is binary false otherwise
73
74       Binary files are invalid for 'svn blame'.
75    */
76    bool binary(void);
77
78    /**
79       @brief Retrieve the blame date for the current line.
80
81       If current line is outside blame entries the behaviour is
82       undefined.
83
84       @return The date.
85    */
86    std::string date(void);
87
88    /**
89       @brief Retrieve the content of the current line.
90
91       If current line is outside blame entries the behaviour is
92       undefined.
93
94       @return The line content.
95    */
96    std::string line(void);
97
98    /**
99       @brief Retrieve the line number of the current line.
100
101       If current line is outside blame entries the behaviour is
102       undefined.
103
104       @return The line number.
105    */
106    apr_int64_t line_no(void);
107
108    /**
109       @brief Skip to the next line.
110
111       @return False if no more blame information is available, true
112       otherwise.
113    */
114    bool next_line(void);
115
116    /**
117       @brief Retrieve the blame revision of the current line.
118
119       If current line is outside blame entries the behaviour is
120       undefined.
121
122       @return The blame revision.
123    */
124    svn_revnum_t revision(void);
125
126    /**
127       @brief Check if more blame information is available.
128
129       @return True if valid information exists, false otherwise.
130    */
131    bool valid(void);
132
133  private:
134
135    /**
136       @brief Copy Constructor, not implemented.
137    */
138    SVNblame(const SVNblame&);
139
140    /**
141       @brief Information return by subversion (blame) API
142
143       @see Subversion API for blame usage.
144    */
145    struct blame_information {
146      apr_int64_t line_no;
147      svn_revnum_t revision;
148      std::string author;
149      std::string date;
150      std::string line;
151    };
152
153    // binary_ is true if item in any revision has been binary.
154    bool binary_;
155    // blame_info_iterator_ is used in statistics analysis to traverse
156    // blame_receiver_baton.blame_info vector through calls to next().
157    std::vector<blame_information*>::iterator blame_info_iterator_;
158    SVN* instance_;
159
160    struct blame_receiver_baton_ {
161      std::vector<blame_information*> blame_info;
162    } blame_receiver_baton_ ;
163
164    static svn_error_t *
165    blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision,
166                   const char *author, const char *date, const char *line,
167                   apr_pool_t *pool);
168  };
169
170}} // end of namespace svndigest and namespace theplu
171
172#endif
Note: See TracBrowser for help on using the repository browser.