source: trunk/lib/SVNlog.h @ 693

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

Fixes #339. Change to GPLv3.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1#ifndef _theplu_svndigest_svnlog_
2#define _theplu_svndigest_svnlog_
3
4// $Id: SVNlog.h 693 2008-09-11 20:42:56Z jari $
5
6/*
7  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
8
9  This file is part of svndigest, http://dev.thep.lu.se/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 3 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 svndigest. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "SVN.h"
26
27#include "Commitment.h"
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 SVNlog class is a utility class for taking care of 'svn
41     log' information. An 'svn log' is performed on an item, the
42     log information for each revision is a vector<Commitment>.
43  */
44  class SVNlog {
45  public:
46    /**
47       Default constructor. Creates empty log.
48     */
49    SVNlog(void);
50
51    /**
52       \brief The contructor.
53       
54       The constructor performs an 'svn log' on \a path and
55       stores the information for later access.
56    */
57    explicit SVNlog(const std::string& path);
58
59    /**
60       \brief The destructor.
61    */
62    ~SVNlog(void);
63
64    /**
65       \return Commitments
66    */
67    inline const std::vector<Commitment>& commits(void) const
68    { return lb_.commits; }
69
70    /**
71       \return Commitments
72    */
73    inline std::vector<Commitment>& commits(void)
74    { return lb_.commits; }
75
76    /**
77       \return true if \a author appears in log.
78    */
79    bool exist(std::string author) const;
80
81    /**
82       \return Latest commit
83    */
84    const Commitment& latest_commit(void) const;
85
86    /**
87       \return Latest commit \a author did. If no author is found an
88       empty Commitment (default constructor) is returned.
89    */
90    const Commitment& latest_commit(std::string author) const;
91
92    /**
93     */
94    void swap(SVNlog&);
95   
96  private:
97
98    ///
99    /// @brief Copy Constructor, not implemented.
100    ///
101    // using compiler generated copy constructor
102    //SVNlog(const SVNlog&);
103
104    /**
105       log information is stored in the log_receiver_baton. The
106       information is retrieved with the info_* set of member
107       functions. The struct is filled in the info_receiver function.
108
109       \see info_receiver
110    */
111    struct log_receiver_baton {
112      std::vector<Commitment> commits;
113    } lb_;
114
115    /**
116       info_receiver is the function passed to the underlying
117       subversion API. This function is called by the subversion API
118       for every item matched by the conditions of the API call.
119
120       \see Subversion API documentation
121    */
122    // The return type should be svn_log_message_receiver_t but I
123    // cannot get it to compile. The svn API has a typedef like
124    // typedef svn_error_t*(* svn_log_message_receiver_t)(void *baton,
125    // apr_hash_t *changed_paths, svn_revnum_t revision, const char
126    // *author, const char *date,const char *message, apr_pool_t
127    // *pool) for svn_log_message_receiver_t.
128    static svn_error_t*
129    log_message_receiver(void *baton, apr_hash_t *changed_paths,
130                         svn_revnum_t rev, const char *author, const char *date,
131                         const char *msg, apr_pool_t *pool);
132  };
133
134  /**
135   */
136  SVNlog& operator+=(SVNlog&, const SVNlog&);
137
138}} // end of namespace svndigest and namespace theplu
139
140#endif
Note: See TracBrowser for help on using the repository browser.