source: trunk/lib/SVNblame.cc @ 163

Last change on this file since 163 was 149, checked in by Jari Häkkinen, 15 years ago

Changed svnstat to svndigest.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1// $Id: SVNblame.cc 149 2006-08-12 09:11:46Z jari $
2
3/*
4  Copyright (C) 2006 Jari Häkkinen
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 "SVNblame.h"
25#include "SVN.h"
26
27#include <string>
28
29namespace theplu {
30namespace svndigest {
31
32
33  SVNblame::SVNblame(const std::string& path)
34    : binary_(false), instance_(SVN::instance())
35  {
36    if (svn_error_t* err=
37        instance_->client_blame(path.c_str(), blame_receiver,
38                                static_cast<void*>(&blame_receiver_baton_))) {
39      // SVN_ERR_CLIENT_IS_BINARY_FILE is the only error allowed to
40      // escape the client_blame call
41      svn_error_clear(err);
42      binary_=true;
43    }
44    blame_info_iterator_ = blame_receiver_baton_.blame_info.begin();
45  }
46
47
48  SVNblame::~SVNblame(void)
49  {
50    std::vector<blame_information*>::iterator i=
51      blame_receiver_baton_.blame_info.begin();
52    while (i!=blame_receiver_baton_.blame_info.end()) {
53      delete *i;
54      ++i;
55    }
56  }
57
58
59  const SVNblame::blame_information* SVNblame::next(void)
60  {
61    blame_information *bi=NULL;
62    if (blame_info_iterator_!=blame_receiver_baton_.blame_info.end()) {
63      bi=*blame_info_iterator_;
64      ++blame_info_iterator_;
65    }
66    return bi;
67  }
68
69
70  svn_error_t *
71  SVNblame::blame_receiver(void *baton, apr_int64_t line_no,
72                           svn_revnum_t revision, const char *author,
73                           const char *date, const char *line, apr_pool_t *pool)
74  {
75    blame_information *bi=new blame_information;
76    bi->line_no=line_no;
77    bi->revision=revision;
78    bi->author=author;
79    bi->date=date;
80    bi->line=line;
81    static_cast<struct blame_receiver_baton_*>(baton)->blame_info.push_back(bi);
82    return SVN_NO_ERROR;
83  }
84
85
86}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.