Changeset 1478 for trunk


Ignore:
Timestamp:
May 29, 2012, 12:17:04 PM (8 years ago)
Author:
Peter Johansson
Message:

closes #387

Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/AddStats.cc

    r1418 r1478  
    44  Copyright (C) 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009, 2010 Peter Johansson
     6  Copyright (C) 2009, 2010, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2626#include "SVNblame.h"
    2727#include "SVNlog.h"
    28 #include "utility.h"
    2928
    3029#include <algorithm>
     
    5251
    5352
    54   void AddStats::do_parse(const std::string& path, svn_revnum_t rev)
     53  void AddStats::do_parse(const std::string& path, svn_revnum_t first_rev)
    5554  {
     55    first_rev = std::max(first_rev, ignore_rev()+1);
    5656    // FIXME: why not using the log from File object
    5757    SVNlog log(path);
     
    6060    std::vector<std::map<std::string, SparseVector> > data;
    6161    std::transform(log.commits().begin(), log.commits().end(),
    62                    std::inserter(revs, revs.begin()), 
     62                   std::inserter(revs, revs.begin()),
    6363                   std::mem_fun_ref(&Commitment::revision));
    6464    for (RevSet::iterator rev_iter=revs.begin();
    65          rev_iter!=revs.end() && *rev_iter>=rev; ++rev_iter){
     65         rev_iter!=revs.end() && *rev_iter>=first_rev; ++rev_iter){
    6666      SVNblame svn_blame(path, *rev_iter);
    6767      LineTypeParser parser(path);
     
    101101
    102102
    103   unsigned int AddStats::max_element(const SumVector& v) const 
     103  unsigned int AddStats::max_element(const SumVector& v) const
    104104  {
    105105    if (v.size()==0)
  • trunk/lib/BlameStats.cc

    r1418 r1478  
    44  Copyright (C) 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009, 2010 Peter Johansson
     6  Copyright (C) 2009, 2010, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2424#include "BlameStats.h"
    2525
    26 #include "Functor.h"
    2726#include "SVNblame.h"
    2827#include "SVNinfo.h"
    2928#include "SVNlog.h"
    30 #include "utility.h"
    3129#include "Vector.h"
    3230
     
    6563  void BlameStats::do_parse(const std::string& path, svn_revnum_t first_rev)
    6664  {
     65    first_rev = std::max(first_rev, ignore_rev()+1);
    6766    // FIXME: using log from File object
    6867    SVNlog log(path);
     
    7069    RevSet revs;
    7170    std::transform(log.commits().begin(), log.commits().end(),
    72                    std::inserter(revs, revs.begin()), 
     71                   std::inserter(revs, revs.begin()),
    7372                   std::mem_fun_ref(&Commitment::revision));
    7473    // we use a ParseVector here to be able to detect when people are
     
    8382        assert(static_cast<size_t>(lt)<data.size());
    8483        SparseVector& vec = data[lt][svn_blame.author()];
    85         vec.set(*rev_iter, vec[*rev_iter] + 1);
    86         add_author(svn_blame.author());
    87         // I dont trust blame and log behave consistently (stop-on-copy).
    88         revs.insert(svn_blame.revision());
     84        if (svn_blame.revision()>ignore_rev()) {
     85          vec.set(*rev_iter, vec[*rev_iter] + 1);
     86          add_author(svn_blame.author());
     87          // I dont trust blame and log behave consistently (stop-on-copy).
     88          revs.insert(svn_blame.revision());
     89        }
    8990        svn_blame.next_line();
    9091      }
     
    100101      typedef std::map<std::string,SparseVector>::const_iterator const_iterator;
    101102      for (const_iterator av = data[lt].begin(); av!=data[lt].end(); ++av) {
    102         for (RevSet::const_reverse_iterator rev_iter=revs.rbegin(); 
     103        for (RevSet::const_reverse_iterator rev_iter=revs.rbegin();
    103104             rev_iter!=revs.rend() && *rev_iter >= first_rev; ++rev_iter) {
    104105          stats_[lt][av->first].set(*rev_iter, data[lt][av->first][*rev_iter]);
  • trunk/lib/ClassicStats.cc

    r1418 r1478  
    44  Copyright (C) 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009, 2010 Peter Johansson
     6  Copyright (C) 2009, 2010, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    6262  void ClassicStats::do_parse(const std::string& path, svn_revnum_t rev)
    6363  {
     64    svn_revnum_t first_rev = ignore_rev() + 1;
    6465    reset();
    6566    LineTypeParser parser(path);
     
    6970      LineTypeParser::line_type lt = parser.parse(svn_blame.line());
    7071      assert(static_cast<size_t>(lt)<data.size());
    71       SparseVector& vec = data[lt][svn_blame.author()];
    72       vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1);
     72      if (svn_blame.revision()>=first_rev) {
     73        SparseVector& vec = data[lt][svn_blame.author()];
     74        vec.set(svn_blame.revision(), vec[svn_blame.revision()] + 1);
     75      }
    7376      svn_blame.next_line();
    7477    }
  • trunk/lib/CopyrightStats.cc

    r1457 r1478  
    22
    33/*
    4   Copyright (C) 2011 Peter Johansson
     4  Copyright (C) 2011, 2012 Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    6060        ss << i->begin() << "-" << i->end();
    6161      ss << ";";
    62   }
     62    }
    6363    config_ = ss.str();
    6464    init(ignore_cache, year2rev);
  • trunk/lib/File.cc

    r1321 r1478  
    33/*
    44  Copyright (C) 2005, 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2010 Peter Johansson
     5  Copyright (C) 2010, 2012 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    5252
    5353
    54   File::File(const unsigned int level, const std::string& path, 
    55              const std::string& output) 
     54  File::File(const unsigned int level, const std::string& path,
     55             const std::string& output)
    5656    : Node(level,path,output)
    5757  {
     
    7070
    7171  std::string File::href(void) const
    72   { 
    73     return name()+".html"; 
     72  {
     73    return name()+".html";
    7474  }
    7575
     
    9292
    9393
    94   const StatsCollection& File::parse(bool verbose, bool ignore)
     94  const StatsCollection& File::parse(bool verbose, bool ignore,
     95                                     svn_revnum_t ignore_rev)
    9596  {
    9697    if (verbose)
    97       std::cout << "Parsing '" << path_ << "'" << std::endl; 
     98      std::cout << "Parsing '" << path_ << "'" << std::endl;
    9899    stats_.reset();
     100    stats_.ignore_rev(ignore_rev);
    99101    std::string cache_file = cache_name();
    100102    std::string cache_dir = directory_name(cache_file);
     
    107109      is.close();
    108110    }
    109     else 
     111    else
    110112      stats_.parse(path_);
    111113    if (!node_exist(cache_dir))
  • trunk/lib/File.h

    r1293 r1478  
    66/*
    77  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009, 2010 Peter Johansson
     8  Copyright (C) 2009, 2010, 2012 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2626#include "Node.h"
    2727
     28#include <subversion-1/svn_types.h>
     29
    2830#include <string>
    2931
     
    3638  {
    3739  public:
    38     /// 
    39     /// @brief Default Constructor 
    40     /// 
    41     File(const unsigned int level, const std::string& path, 
    42          const std::string& output=""); 
     40    ///
     41    /// @brief Default Constructor
     42    ///
     43    File(const unsigned int level, const std::string& path,
     44         const std::string& output="");
    4345
    4446    /**
     
    6769    /// @brief Parsing out information from svn repository
    6870    ///
     71    /// if \a ignore true, ignore cache file (read from repo).
     72    /// ignore revision in range [0, ignore_rev]
     73    ///
    6974    /// @return Stats object of the file
    7075    ///
    71     const StatsCollection& parse(bool verbose, bool ignore);
     76    const StatsCollection& parse(bool verbose, bool ignore,
     77                                 svn_revnum_t ignore_rev);
    7278
    7379    /**
     
    9298
    9399#endif
    94 
    95 
  • trunk/lib/SVNproperty.cc

    r1454 r1478  
    44  Copyright (C) 2006 Jari Häkkinen
    55  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2010 Peter Johansson
     6  Copyright (C) 2010, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4040namespace svndigest {
    4141
     42  using yat::utility::convert;
    4243
    4344  SVNproperty::SVNproperty(const std::string& path)
    44     : binary_(false), svncopyright_ignore_(false), svndigest_ignore_(false)
     45    : binary_(false), svncopyright_ignore_(false), svndigest_ignore_rev_(0)
    4546  {
    4647    typedef std::map<std::string, std::string> str_map;
     
    6162      try {
    6263        if (i->first == "svndigest:ignore")
    63           svndigest_ignore_=true;
     64          add_svndigest_ignore(i->second);
    6465        else if (i->first == "svncopyright:ignore")
    6566          add_svncopyright_ignore(i->second);
     
    102103      trim(second);
    103104      yat::utility::Segment<svn_revnum_t> rev_interval;
    104       using yat::utility::convert;
    105105      if (!found_dash) {
    106106        rev_interval.begin() = convert<svn_revnum_t>(first);
     
    122122
    123123
     124  void SVNproperty::add_svndigest_ignore(const std::string& value)
     125  {
     126    if (value.empty() || value=="*") {
     127      svndigest_ignore_rev_ = std::numeric_limits<svn_revnum_t>::max();
     128      return;
     129    }
     130    svndigest_ignore_rev_ = convert<svn_revnum_t>(value);
     131  }
     132
     133
    124134  bool SVNproperty::binary(void) const
    125135  {
     
    130140  bool SVNproperty::svndigest_ignore(void) const
    131141  {
    132     return svndigest_ignore_;
     142    return svndigest_ignore_rev_==std::numeric_limits<svn_revnum_t>::max();
     143  }
     144
     145
     146  svn_revnum_t SVNproperty::svndigest_ignore_rev(void) const
     147  {
     148    return svndigest_ignore_rev_;
    133149  }
    134150
  • trunk/lib/SVNproperty.h

    r1438 r1478  
    77  Copyright (C) 2006 Jari Häkkinen
    88  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2010 Peter Johansson
     9  Copyright (C) 2010, 2012 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    7070    */
    7171    bool svndigest_ignore(void) const;
     72    svn_revnum_t svndigest_ignore_rev(void) const;
    7273
    7374    /**
     
    101102
    102103    void add_svncopyright_ignore(const std::string& value);
     104    void add_svndigest_ignore(const std::string& value);
    103105
    104106    bool binary_;
    105107    bool svncopyright_ignore_;
    106     bool svndigest_ignore_;
    107108    yat::utility::SegmentSet<svn_revnum_t> svncopyright_ignore_rev_;
     109    svn_revnum_t svndigest_ignore_rev_;
    108110  };
    109111
  • trunk/lib/Stats.cc

    r1378 r1478  
    44  Copyright (C) 2005 Peter Johansson
    55  Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2010, 2011 Peter Johansson
     6  Copyright (C) 2010, 2011, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    5050
    5151  Stats::Stats(const std::string& path)
    52     : stats_(std::vector<Author2Vector>(LineTypeParser::total+1))
     52    : stats_(std::vector<Author2Vector>(LineTypeParser::total+1)),
     53      ignore_rev_(0)
    5354  {
    5455    // Make sure latest revision is set properly
     
    6566  }
    6667
    67  
     68
    6869  void Stats::add(const std::vector<std::map<std::string, SparseVector> >& data)
    6970  {
     
    118119  */
    119120  /*
    120   void Stats::add(const std::string& user, svn_revnum_t rev, 
     121  void Stats::add(const std::string& user, svn_revnum_t rev,
    121122                  LineTypeParser::line_type lt, unsigned int n)
    122123  {
     
    135136
    136137  void Stats::add(SumVector& vec, svn_revnum_t rev, unsigned int n)
    137   { 
     138  {
    138139    vec.set(rev, vec[rev] + n);
    139140  }
     
    147148
    148149
    149   void Stats::add_authors(std::set<std::string>::const_iterator first, 
     150  void Stats::add_authors(std::set<std::string>::const_iterator first,
    150151                          std::set<std::string>::const_iterator last)
    151152  {
     
    218219
    219220
     221  std::string Stats::config_code(void) const
     222  {
     223    if (ignore_rev_==0)
     224      return config_code_;
     225    std::stringstream result(config_code_);
     226    result << "ir" << ignore_rev_;
     227    return result.str();
     228  }
     229
     230
    220231  unsigned int Stats::empty(const std::string& user) const
    221232  {
     
    227238  {
    228239    A2VConstIter iter(m.find(std::string(user)));
    229     if (iter==m.end() || iter->second.empty()) 
     240    if (iter==m.end() || iter->second.empty())
    230241      return 0;
    231242    return iter->second.back();
     
    233244
    234245
    235   const SumVector& Stats::get_vector(const Author2Vector& m, 
     246  const SumVector& Stats::get_vector(const Author2Vector& m,
    236247                                     const std::string& user) const
    237248  {
    238249    A2VConstIter iter(m.find(std::string(user)));
    239     if (iter==m.end()) 
     250    if (iter==m.end())
    240251      throw std::runtime_error(user+std::string(" not found i Stats"));
    241252    return iter->second;
     253  }
     254
     255
     256  void Stats::ignore_rev(svn_revnum_t rev)
     257  {
     258    ignore_rev_ = rev;
     259  }
     260
     261
     262  const svn_revnum_t& Stats::ignore_rev(void) const
     263  {
     264    return ignore_rev_;
    242265  }
    243266
     
    303326    std::string line;
    304327    getline(is, line);
    305     if (line!=config_code_) {
     328    if (line!=config_code()) {
    306329      std::cout << "cache file is for different configuration.\n"
    307                 << "config code: '" << config_code_ << "'\n"
     330                << "config code: '" << config_code() << "'\n"
    308331                << "config code in cache file: '" << line << "'\n"
    309332                << "retrieving statistics from repository.\n";
     
    342365
    343366
    344   void Stats::map_add(A2VConstIter first1, A2VConstIter last1, 
     367  void Stats::map_add(A2VConstIter first1, A2VConstIter last1,
    345368                      Author2Vector& map)
    346369  {
    347370    A2VIter first2(map.begin());
    348371    Author2Vector::key_compare compare;
    349     while ( first1 != last1) { 
     372    while ( first1 != last1) {
    350373      // key of first1 less than key of first2
    351374      if (first2==map.end() || compare(first1->first,first2->first)) {
     
    369392  unsigned int Stats::max_element(const SumVector& vec) const
    370393  {
    371     return std::max_element(vec.begin(), vec.end(), 
     394    return std::max_element(vec.begin(), vec.end(),
    372395       pair_value_compare<const svn_revnum_t, unsigned int>())->second;
    373396  }
     
    380403    calc_total();
    381404    calc_all();
    382    
     405
    383406    assert(total_stats().size());
    384407    assert(code_stats().size());
     
    394417    // be used from load_cache8().
    395418    os << "CACHE FILE VERSION 8\n";
    396     os << config_code_ << "\n";
     419    os << config_code() << "\n";
    397420    os << last_changed_rev() << " ";
    398421    os << authors().size() << "\n";
    399422
    400     std::copy(authors().begin(), authors().end(), 
     423    std::copy(authors().begin(), authors().end(),
    401424              std::ostream_iterator<std::string>(os, "\n"));
    402425    os << cache_check_str() << "\n";
     
    454477
    455478
    456   svn_revnum_t Stats::revision(void) const 
    457   { 
    458     return revision_; 
     479  svn_revnum_t Stats::revision(void) const
     480  {
     481    return revision_;
    459482  }
    460483
     
    468491    for (size_t i=0; i<stats_.size(); ++i)
    469492      map_add(rhs.stats_[i].begin(), rhs.stats_[i].end(), stats_[i]);
    470    
     493
    471494    return *this;
    472495  }
    473496
    474  
    475   size_t Stats::operator()(int linetype, std::string author, 
     497
     498  size_t Stats::operator()(int linetype, std::string author,
    476499                           svn_revnum_t rev) const
    477500  {
     
    482505    if (i==stats_[linetype].end()){
    483506      std::stringstream msg;
    484       msg << __FILE__ << ": author: " << author << " does not exist"; 
     507      msg << __FILE__ << ": author: " << author << " does not exist";
    485508      throw std::runtime_error(msg.str());
    486509    }
  • trunk/lib/Stats.h

    r1321 r1478  
    77  Copyright (C) 2005 Peter Johansson
    88  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2010 Peter Johansson
     9  Copyright (C) 2010, 2012 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4545  {
    4646  public:
    47     /// 
    48     /// @brief Default Constructor 
     47    ///
     48    /// @brief Default Constructor
    4949    ///
    5050    explicit Stats(const std::string& path);
     
    6161
    6262    ///
    63     /// \return number of code lines for \a user for latest revision. 
    64     ///
    65     unsigned int code(const std::string& user="all") const; 
    66 
    67 
    68     ///
    69     /// \return number of comments lines for \a user for latest revision. 
    70     ///
    71     unsigned int comments(const std::string& user="all") const; 
    72 
    73     ///
    74     /// \return number of empty lines for \a user for latest revision. 
    75     ///
    76     unsigned int empty(const std::string& user="all") const; 
     63    /// \return number of code lines for \a user for latest revision.
     64    ///
     65    unsigned int code(const std::string& user="all") const;
     66
     67
     68    ///
     69    /// \return number of comments lines for \a user for latest revision.
     70    ///
     71    unsigned int comments(const std::string& user="all") const;
     72
     73    ///
     74    /// \return number of empty lines for \a user for latest revision.
     75    ///
     76    unsigned int empty(const std::string& user="all") const;
    7777
    7878    ///
     
    8484    /// \return number of lines for \a user for latest revision
    8585    ///
    86     unsigned int lines(const std::string& user="all") const; 
     86    unsigned int lines(const std::string& user="all") const;
    8787
    8888    /**
     
    109109    /// @brief Clear all statistics
    110110    ///
    111     void reset(void); 
     111    void reset(void);
    112112
    113113    /**
     
    120120    ///
    121121    svn_revnum_t revision(void) const;
     122
     123    /**
     124       \brief set (greatest) revision to be ignored
     125     */
     126    void ignore_rev(svn_revnum_t rev);
    122127
    123128    /**
     
    146151
    147152    void add_author(std::string);
    148     void add_authors(std::set<std::string>::const_iterator, 
     153    void add_authors(std::set<std::string>::const_iterator,
    149154                     std::set<std::string>::const_iterator);
    150155
    151156    // references to data
    152     inline Author2Vector& code_stats(void) 
     157    inline Author2Vector& code_stats(void)
    153158    { return stats_[LineTypeParser::code]; }
    154     inline Author2Vector& comment_stats(void) 
     159    inline Author2Vector& comment_stats(void)
    155160    { return stats_[LineTypeParser::comment]; }
    156     inline Author2Vector& copyright_stats(void) 
     161    inline Author2Vector& copyright_stats(void)
    157162    { return stats_[LineTypeParser::copyright]; }
    158     inline Author2Vector& other_stats(void) 
     163    inline Author2Vector& other_stats(void)
    159164    { return stats_[LineTypeParser::other]; }
    160     inline Author2Vector& comment_or_copy_stats(void) 
     165    inline Author2Vector& comment_or_copy_stats(void)
    161166    { return stats_[LineTypeParser::comment_or_copy]; }
    162     inline Author2Vector& total_stats(void) 
     167    inline Author2Vector& total_stats(void)
    163168    { return stats_[LineTypeParser::total]; }
    164169
     
    178183
    179184    /**
     185       const access to ignore_rev_
     186     */
     187    const svn_revnum_t& ignore_rev(void) const;
     188
     189    /**
    180190       add range [\a first, \a last) to \a map
    181191     */
    182     void map_add(Author2Vector::const_iterator first, 
     192    void map_add(Author2Vector::const_iterator first,
    183193                 Author2Vector::const_iterator last,
    184194                 Author2Vector& map);
     
    186196    std::set<std::string> authors_;
    187197
    188     const SumVector& get_vector(const Author2Vector&, 
     198    const SumVector& get_vector(const Author2Vector&,
    189199                                const std::string& user) const;
    190200  private:
     
    196206
    197207    /**
     208       \return config_code unless ignore_rev_!=0 in which case
     209       ignore_rev_ is appended to returned string
     210     */
     211    std::string config_code(void) const;
     212
     213    /**
    198214       Parse statistics for fundamental categories, i.e., code,
    199215       comment, empty, and copyright for each author. Ignore revisions
     
    201217     */
    202218    virtual void do_parse(const std::string&, svn_revnum_t first_rev)=0;
    203    
     219
    204220    /// load cache file version 7
    205221    svn_revnum_t load_cache7(std::istream&);
     
    209225    // Change this string if cache format is changed in such a way
    210226    // that all old cache files are obsolete.
    211     inline std::string cache_check_str(void) const 
    212     {return "CACHE FILE VERSION 7";} 
     227    inline std::string cache_check_str(void) const
     228    {return "CACHE FILE VERSION 7";}
    213229
    214230    void calc_all(void);
     
    223239       in linear time.
    224240
    225        \return the largest largest element in \a v. 
    226     */
    227     virtual unsigned int max_element(const SumVector& v) const; 
     241       \return the largest largest element in \a v.
     242    */
     243    virtual unsigned int max_element(const SumVector& v) const;
    228244
    229245    void print(std::ostream& os, const Author2Vector& m) const;
    230246
     247    svn_revnum_t ignore_rev_;
    231248    svn_revnum_t revision_; // Should be the latest revision for whole project
    232249    svn_revnum_t last_changed_rev_; // Should be the latest revision for file
     
    241258}} // end of namespace svndigest end of namespace theplu
    242259
    243 #endif 
     260#endif
  • trunk/lib/StatsCollection.cc

    r1124 r1478  
    44  Copyright (C) 2007 Peter Johansson
    55  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    6   Copyright (C) 2009, 2010 Peter Johansson
     6  Copyright (C) 2009, 2010, 2012 Peter Johansson
    77
    88  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    108108
    109109
     110  void StatsCollection::ignore_rev(svn_revnum_t rev)
     111  {
     112    for (map::const_iterator i(stats_.begin()); i!=stats_.end(); ++i) {
     113      i->second->ignore_rev(rev);
     114    }
     115  }
     116
     117
    110118  const StatsCollection& StatsCollection::operator+=(const StatsCollection& rhs)
    111119  {
     
    122130    map::const_iterator iter = stats_.find(key);
    123131    if (iter==stats_.end())
    124       throw std::runtime_error(key + 
     132      throw std::runtime_error(key +
    125133                               std::string(" not found in StatsCollection"));
    126134    return *(iter->second);
  • trunk/lib/StatsCollection.h

    r1081 r1478  
    77  Copyright (C) 2007 Peter Johansson
    88  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2010 Peter Johansson
     9  Copyright (C) 2010, 2012 Peter Johansson
    1010
    1111  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2727#include "Stats.h"
    2828
     29#include <subversion-1/svn_types.h>
     30
    2931#include <map>
    3032#include <string>
     
    3941  {
    4042  public:
    41     /// 
    42     /// @brief Default Constructor 
     43    ///
     44    /// @brief Default Constructor
    4345    ///
    4446    explicit StatsCollection(const std::string& path);
     
    6769     */
    6870    void reset(void);
     71
     72    /**
     73     */
     74    void ignore_rev(svn_revnum_t rev);
    6975
    7076    const std::map<std::string, Stats*>& stats(void) const;
     
    97103}} // end of namespace svndigest end of namespace theplu
    98104
    99 #endif 
     105#endif
  • trunk/lib/SvndigestVisitor.cc

    r1449 r1478  
    22
    33/*
    4   Copyright (C) 2010 Peter Johansson
     4  Copyright (C) 2010, 2012 Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2828#include "NodeVisitor.h"
    2929
     30#include <algorithm>
     31
    3032namespace theplu {
    3133namespace svndigest {
     
    3941  bool SvndigestVisitor::enter(Directory& dir)
    4042  {
     43    svn_revnum_t r = dir.property().svndigest_ignore_rev();
     44    if (ignore_rev_.size() && r<ignore_rev_.back())
     45      ignore_rev_.push_back(ignore_rev_.back());
     46    ignore_rev_.push_back(r);
    4147    if (dir.svndigest_ignore())
    4248      return false;
     
    4753  void SvndigestVisitor::leave(Directory& dir)
    4854  {
     55    assert(ignore_rev_.size());
     56    ignore_rev_.pop_back();
    4957    if (report_) {
    5058      dir.collect_stats();
     
    5866  void SvndigestVisitor::visit(File& file)
    5967  {
    60     if (!file.svndigest_ignore())
    61       file.parse(verbose_, ignore_cache_);
     68    if (!file.svndigest_ignore()) {
     69      svn_revnum_t rev = file.property().svndigest_ignore_rev();
     70      assert(ignore_rev_.size());
     71      rev = std::max(rev, ignore_rev_.back());
     72      file.parse(verbose_, ignore_cache_, rev);
     73    }
    6274    if (report_) {
    6375      file.init_tiny_stats();
  • trunk/lib/SvndigestVisitor.h

    r1234 r1478  
    55
    66/*
    7   Copyright (C) 2010 Peter Johansson
     7  Copyright (C) 2010, 2012 Peter Johansson
    88
    99  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2424
    2525#include "NodeVisitor.h"
     26
     27#include <subversion-1/svn_types.h>
     28
     29#include <vector>
    2630
    2731namespace theplu{
     
    5458    bool ignore_cache_;
    5559    bool report_;
     60    std::vector<svn_revnum_t> ignore_rev_;
    5661  };
    5762}} // end of namespace svndigest and namespace theplu
  • trunk/test/Makefile.am

    r1470 r1478  
    2626AM_DEFAULT_SOURCE_EXT = .cc
    2727
    28 EXTRA_PROGRAMS = cache_partial.test color.test \
     28EXTRA_PROGRAMS = cache.test cache_partial.test color.test \
    2929  config.test copyright.test date.test \
    30   graph.test htmlstream.test \
     30  graph.test htmlstream.test ignore_rev.test \
    3131  parser.test option.test stats.test svn_diff.test trac.test utility.test \
    3232  vector.test
     
    8484libsvndigesttest_a_SOURCES = Suite.cc
    8585
    86 clean-local: 
     86clean-local:
    8787  rm -rf generated_output toy_project testSubDir
    8888
    89 mostlyclean-local: 
    90   rm -f *.png *.tmp *~ 
     89mostlyclean-local:
     90  rm -f *.png *.tmp *~
    9191
    9292.PHONY: lazycheck
    9393
    94 lazycheck:; $(MAKE) $(AM_MAKEFLAGS) check RECHECK_LOGS= 
     94lazycheck:; $(MAKE) $(AM_MAKEFLAGS) check RECHECK_LOGS=
    9595
    9696if HAVE_SVN_WC
    97 repo_stamp = $(srcdir)/repo/db/current
     97repo_stamp = $(srcdir)/repo/db/current svn_update.sh
    9898else
    9999repo_stamp =
     
    109109link_root_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT) $(repo_stamp)
    110110permission_test.log:init.sh $(top_builddir)/bin/svncopyright$(EXEEXT) $(repo_stamp)
    111 repo_status_test.log:init.sh 
     111repo_status_test.log:init.sh
    112112repo_test.log:init.sh $(top_builddir)/bin/svndigest$(EXEEXT) $(repo_stamp)
    113113svncopyright_test.log:init.sh $(top_builddir)/bin/svncopyright$(EXEEXT)
     
    118118copyright.log: $(repo_stamp)
    119119stats.log: $(repo_stamp)
    120 
  • trunk/test/Suite.cc

    r1435 r1478  
    33/*
    44  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2009, 2010 Peter Johansson
     5  Copyright (C) 2009, 2010, 2012 Peter Johansson
    66
    77  This file is part of the yat library, http://dev.thep.lu.se/yat
     
    3131
    3232#include <algorithm>
     33#include <cstdlib>
    3334#include <fstream>
    3435#include <iostream>
    3536#include <iterator>
     37#include <sstream>
     38#include <stdexcept>
    3639#include <string>
    3740
     
    301304  {
    302305    std::string cmd = abs_builddir()+"/svn_update.sh";
    303     out() << cmd << std::endl;
    304     int status = system(cmd.c_str());
    305     if (status) {
    306       out() << "failed with status: " << status << std::endl;
     306    try {
     307      system(cmd, 0);
     308    }
     309    catch (std::runtime_error& e) {
     310      out() << e.what() << "\n";
    307311      exit (1);
    308312    }
     
    329333
    330334
     335  void Suite::system(const std::string& cmd, int ret) const
     336  {
     337    int status = ::system(cmd.c_str());
     338    out() << "call: '" << cmd << "'\n";
     339    if (status==ret)
     340      return;
     341    std::stringstream ss;
     342    ss << "error: status: " << status;
     343    throw std::runtime_error(ss.str());
     344  }
    331345}}}
  • trunk/test/Suite.h

    r1207 r1478  
    66/*
    77  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2009, 2010 Peter Johansson
     8  Copyright (C) 2009, 2010, 2012 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    6464
    6565    /**
     66       Wrapper around std system that calls \a cmd to shell. If return
     67       value is different from \a xret exception is thrown
     68    */
     69    void system(const std::string& cmd, int xret=0) const;
     70
     71    /**
    6672       \return true if we are running in verbose mode
    6773     */
     
    102108   */
    103109  std::string src_filename(const std::string& path);
     110
     111
    104112}}}
    105113
  • trunk/test/cache_partial.cc

    r1321 r1478  
    22
    33/*
    4   Copyright (C) 2009, 2010 Peter Johansson
     4  Copyright (C) 2009, 2010, 2012 Peter Johansson
    55
    66  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    5454  std::string cache_file = "toy_project/.svndigest/AUTHORS.svndigest-cache";
    5555  File file(0,filename,"");
    56   const StatsCollection& stats1 = file.parse(suite.verbose(), true);
     56  const StatsCollection& stats1 = file.parse(suite.verbose(), true, 0);
    5757  suite.add(test::consistent(stats1, suite));
    5858
     
    6060  copy_file(test::src_filename("data/AUTHORS.svndigest-cache-r61"), cache_file);
    6161  File file2(0,filename,"");
    62   const StatsCollection& stats2 = file2.parse(suite.verbose(), false);
     62  const StatsCollection& stats2 = file2.parse(suite.verbose(), false, 0);
    6363  suite.add(test::consistent(stats2, suite));
    6464
Note: See TracChangeset for help on using the changeset viewer.