source: trunk/lib/SvndigestVisitor.cc @ 1523

Last change on this file since 1523 was 1523, checked in by Peter Johansson, 9 years ago

merge release 0.10 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: SvndigestVisitor.cc 1523 2012-09-28 05:48:51Z peter $
2
3/*
4  Copyright (C) 2010, 2011, 2012 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 3 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 svndigest. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "SvndigestVisitor.h"
23
24#include "Directory.h"
25#include "DirectoryPrinter.h"
26#include "File.h"
27#include "FilePrinter.h"
28#include "NodeVisitor.h"
29
30#include <algorithm>
31#include <cassert>
32
33namespace theplu {
34namespace svndigest {
35
36  SvndigestVisitor::SvndigestVisitor(bool verbose, bool ignore_cache,
37                                     bool report)
38    : verbose_(verbose), ignore_cache_(ignore_cache), report_(report)
39  {}
40
41
42  bool SvndigestVisitor::enter(Directory& dir)
43  {
44    svn_revnum_t r = dir.property().svndigest_ignore_rev();
45    if (ignore_rev_.size() && r<ignore_rev_.back())
46      ignore_rev_.push_back(ignore_rev_.back());
47    ignore_rev_.push_back(r);
48    if (dir.svndigest_ignore())
49      return false;
50    return true;
51  }
52
53
54  void SvndigestVisitor::leave(Directory& dir)
55  {
56    assert(ignore_rev_.size());
57    ignore_rev_.pop_back();
58    if (report_) {
59      dir.collect_stats();
60      dir.init_tiny_stats();
61      DirectoryPrinter dp(dir);
62      dp.print(verbose_);
63    }
64  }
65
66
67  void SvndigestVisitor::visit(File& file)
68  {
69    if (!file.svndigest_ignore()) {
70      svn_revnum_t rev = file.property().svndigest_ignore_rev();
71      assert(ignore_rev_.size());
72      rev = std::max(rev, ignore_rev_.back());
73      file.parse(verbose_, ignore_cache_, rev);
74    }
75    if (report_) {
76      file.init_tiny_stats();
77      if (!file.svndigest_ignore()) {
78        FilePrinter fp(file);
79        fp.print(verbose_);
80      }
81    }
82  }
83
84}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.