source: trunk/lib/SVNblame.h @ 380

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

Addresses #62. First blame output with lines.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#ifndef _theplu_svndigest_svnblame_
2#define _theplu_svndigest_svnblame_
3
4// $Id: SVNblame.h 380 2007-06-21 19:25:39Z 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() calls giving access to the blame information in
42  /// a blame_information struct.
43  ///
44  class SVNblame {
45  public:
46
47    ///
48    /// @brief Information return by subversion (blame) API
49    ///
50    /// @see Subversion API for blame usage.
51    ///
52    struct blame_information {
53      apr_int64_t line_no;
54      svn_revnum_t revision;
55      std::string author;
56      std::string date;
57      std::string line;
58    };
59
60    ///
61    /// @brief The contructor.
62    ///
63    /// The constructor performs an 'svn blame' on \a path and
64    /// initializes the SVNblame object for statistics traversal using
65    /// SVNblame::next().
66    ///
67    explicit SVNblame(const std::string& path);
68
69    ///
70    /// @brief The destructor.
71    ///
72    ~SVNblame(void);
73
74    ///
75    /// @brief Returns true if item is binary false otherwise
76    ///
77    /// Binary files are invalid for 'svn blame'.
78    ///
79    inline bool binary(void) { return binary_; }
80
81    /**
82       Traverse all lines in the item for statistics analysis. There
83       is currently no way to reset the pointer to the beginning of
84       item. The pointer is only valid while the SVNblame object is in
85       scope.
86
87       @return Pointer to a blame_information struct if more lines are
88       available NULL otherwise.
89
90       @see struct blame_information.
91    */
92    const blame_information* next(void);
93
94  private:
95
96    ///
97    /// @brief Copy Constructor, not implemented.
98    ///
99    SVNblame(const SVNblame&);
100
101    // binary_ is true if item in any revision has been binary.
102    bool binary_;
103    // blame_info_iterator_ is used in statistics analysis to traverse
104    // blame_receiver_baton.blame_info vector through calls to next().
105    std::vector<blame_information*>::iterator blame_info_iterator_;
106    SVN* instance_;
107
108    struct blame_receiver_baton_ {
109      std::vector<blame_information*> blame_info;
110    } blame_receiver_baton_ ;
111
112    static svn_error_t *
113    blame_receiver(void *baton, apr_int64_t line_no, svn_revnum_t revision,
114                   const char *author, const char *date, const char *line,
115                   apr_pool_t *pool);
116  };
117
118}} // end of namespace svndigest and namespace theplu
119
120#endif
Note: See TracBrowser for help on using the repository browser.