source: trunk/lib/AddStats.cc @ 803

Last change on this file since 803 was 803, checked in by Peter Johansson, 12 years ago

fixes #338 - partial cache now works

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
RevLine 
[84]1// $Id: AddStats.cc 803 2009-07-10 23:23:45Z peter $
[14]2
[84]3/*
[803]4  Copyright (C) 2008, 2009 Peter Johansson
[84]5
[687]6  This file is part of svndigest, http://dev.thep.lu.se/svndigest
[84]7
[149]8  svndigest is free software; you can redistribute it and/or modify it
[84]9  under the terms of the GNU General Public License as published by
[693]10  the Free Software Foundation; either version 3 of the License, or
[84]11  (at your option) any later version.
12
[149]13  svndigest is distributed in the hope that it will be useful, but
[84]14  WITHOUT ANY WARRANTY; without even the implied warranty of
[149]15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
[84]16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
[693]19  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
[84]20*/
21
[543]22#include "AddStats.h"
[129]23
[138]24#include "SVNblame.h"
[537]25#include "SVNlog.h"
[14]26#include "utility.h"
27
[41]28#include <algorithm>
[65]29#include <cassert>
[63]30#include <cstdlib>
[647]31#include <functional>
[14]32#include <map>
33#include <string>
34#include <vector>
35
36namespace theplu{
[149]37namespace svndigest{
[14]38
39
[543]40  AddStats::AddStats(const std::string& path)
[487]41    : Stats(path)
[80]42  {
43  }
44
[529]45
[543]46  AddStats::AddStats(const AddStats& other)
[528]47  : Stats(other)
48  {
49  }
[80]50
[14]51
[664]52  void AddStats::do_parse(const std::string& path, svn_revnum_t rev)
[537]53  {
54    SVNlog log(path);
[664]55    typedef std::set<svn_revnum_t, std::greater<svn_revnum_t> > RevSet;
[537]56    RevSet revs;
[642]57    std::transform(log.commits().begin(), log.commits().end(),
[647]58                   std::inserter(revs, revs.begin()), 
59                   std::mem_fun_ref(&Commitment::revision));
[664]60    for (RevSet::iterator rev_iter=revs.begin();
[703]61         rev_iter!=revs.end() && *rev_iter>=rev; ++rev_iter){
[537]62      SVNblame svn_blame(path, *rev_iter);
[657]63      LineTypeParser parser(path);
[537]64      while (svn_blame.valid()) {
[657]65        LineTypeParser::line_type lt = parser.parse(svn_blame.line());
[543]66        if (*rev_iter==svn_blame.revision())
[657]67          add(svn_blame.author(), *rev_iter, lt);
[803]68        // I dont trust blame and log behave consistently (stop-on-copy).
[537]69        revs.insert(svn_blame.revision());
70        svn_blame.next_line();
71      }
[138]72    }
[664]73    accumulate_stats(rev);
[60]74  }
75
76
[149]77}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.