source: branches/0.6-stable/lib/SVNlog.cc

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: 2.8 KB
Line 
1// $Id: SVNlog.cc 731 2008-12-15 19:03:04Z peter $
2
3/*
4  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
5
6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
7
8  svndigest is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12
13  svndigest is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "SVNlog.h"
25
26#include "Commitment.h"
27#include "SVN.h"
28
29#include <algorithm>
30#include <cassert>
31#include <string>
32#include <vector>
33
34namespace theplu {
35namespace svndigest {
36
37
38  SVNlog::SVNlog(const std::string& path)
39  {
40    SVN::instance()->client_log(path, log_message_receiver,
41                                static_cast<void*>(&lb_));
42    assert(date().size()==author().size());
43    assert(date().size()==revision().size());
44    assert(date().size()==message().size());
45  }
46
47
48  SVNlog::~SVNlog(void)
49  {
50  }
51
52 
53  bool SVNlog::exist(std::string name) const
54  {
55    std::vector<std::string>::const_reverse_iterator iter = 
56      find(author().rbegin(), author().rend(), name);
57    return iter!=author().rend();
58  }
59
60
61  Commitment SVNlog::latest_commit(void) const
62  {
63    return Commitment(author().back(), Date(date().back()), 
64                      message().back(), revision().back());
65                                             
66  }
67
68
69  Commitment SVNlog::latest_commit(std::string name) const
70  {
71    std::vector<std::string>::const_reverse_iterator iter = 
72      find(author().rbegin(), author().rend(), name);
73    size_t dist(std::distance(iter, author().rend()));
74    if (!dist) {
75      Commitment c;
76      assert(false);
77      return c;
78    }
79    return Commitment(author()[dist-1], Date(date()[dist-1]), 
80                      message()[dist-1], revision()[dist-1]);
81                                             
82  }
83
84
85  svn_error_t* 
86  SVNlog::log_message_receiver(void *baton, apr_hash_t *changed_paths,
87                               svn_revnum_t rev, const char *author,
88                               const char *date, const char *msg,
89                               apr_pool_t *pool)
90  {
91    struct log_receiver_baton *lb=static_cast<struct log_receiver_baton*>(baton);
92    if (date && date[0])
93      lb->commit_dates.push_back(date);
94    else
95      throw SVNException("No date defined for revision: " + rev); 
96    if (author && author[0])
97      lb->authors.push_back(author);
98    else
99      lb->authors.push_back("");
100    lb->rev.push_back(rev);
101    if (msg)
102      lb->msg.push_back(std::string(msg));
103    else
104      lb->msg.push_back(std::string(""));
105    return SVN_NO_ERROR;
106  }
107
108}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.