source: trunk/lib/SVNlog.cc @ 282

Last change on this file since 282 was 282, checked in by Peter Johansson, 14 years ago

refs #175

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1// $Id: SVNlog.cc 282 2007-05-06 14:28:18Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of svndigest, http://lev.thep.lu.se/trac/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 <cassert>
30#include <string>
31#include <vector>
32
33namespace theplu {
34namespace svndigest {
35
36
37  SVNlog::SVNlog(std::string path)
38  {
39    SVN* svn = SVN::instance();
40    svn->client_log(path, &lb_);
41    assert(date().size()==author().size());
42    assert(date().size()==revision().size());
43    assert(date().size()==message().size());
44
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}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.