source: trunk/lib/SvndigestVisitor.cc @ 1535

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

add member 'update_' in SvndigestVisitor?. refs #334

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1// $Id: SvndigestVisitor.cc 1535 2012-10-06 03:33:13Z 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, bool update)
38    : verbose_(verbose), ignore_cache_(ignore_cache), report_(report),
39      update_(update)
40  {}
41
42
43  bool SvndigestVisitor::enter(Directory& dir)
44  {
45    svn_revnum_t r = dir.property().svndigest_ignore_rev();
46    if (ignore_rev_.size() && r<ignore_rev_.back())
47      ignore_rev_.push_back(ignore_rev_.back());
48    ignore_rev_.push_back(r);
49    if (dir.svndigest_ignore())
50      return false;
51    return true;
52  }
53
54
55  void SvndigestVisitor::leave(Directory& dir)
56  {
57    assert(ignore_rev_.size());
58    ignore_rev_.pop_back();
59    if (report_) {
60      dir.collect_stats();
61      dir.init_tiny_stats();
62      DirectoryPrinter dp(dir);
63      dp.print(verbose_);
64    }
65  }
66
67
68  void SvndigestVisitor::visit(File& file)
69  {
70    if (!file.svndigest_ignore()) {
71      svn_revnum_t rev = file.property().svndigest_ignore_rev();
72      assert(ignore_rev_.size());
73      rev = std::max(rev, ignore_rev_.back());
74      file.parse(verbose_, ignore_cache_, rev);
75    }
76    if (report_) {
77      file.init_tiny_stats();
78      if (!file.svndigest_ignore()) {
79        FilePrinter fp(file);
80        fp.print(verbose_);
81      }
82    }
83  }
84
85}} // end of namespace svndigest and namespace theplu
Note: See TracBrowser for help on using the repository browser.