Changeset 1438


Ignore:
Timestamp:
Dec 20, 2011, 5:01:36 AM (9 years ago)
Author:
Peter Johansson
Message:

refs #387. extending svncopyrigt property in SVNproperty to hold which revs to ignore rather than just yes/no

Location:
trunk
Files:
7 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/CopyrightStats.cc

    r1380 r1438  
    4444    : path_(path)
    4545  {
    46     cache_file_ = concatenate_path(concatenate_path(directory_name(path), 
     46    cache_file_ = concatenate_path(concatenate_path(directory_name(path),
    4747                                                    ".svndigest"),
    4848                                   file_name(path)+".svncopyright-cache");
     
    5252
    5353
    54   void CopyrightStats::init(bool ignore_cache, 
     54  void CopyrightStats::init(bool ignore_cache,
    5555                            const std::map<int, svn_revnum_t>& year2rev)
    5656  {
     
    6363
    6464    // reset stats if cache was invalid
    65     if (cache_rev == 0) 
     65    if (cache_rev == 0)
    6666      reset();
    6767
     
    143143      assert(yearrev!=year2rev.end());
    144144      assert(yearrev->second >= commit->revision());
    145      
     145
    146146      const std::string& name = commit->author();
    147147      // skip if alias already has copyright for this year.
    148       std::map<int, std::set<std::string> >::const_iterator year_users = 
     148      std::map<int, std::set<std::string> >::const_iterator year_users =
    149149        year2user_.find(yearrev->first);
    150       if (year_users!=year2user_.end() 
     150      if (year_users!=year2user_.end()
    151151          && year_users->second.count(name))
    152152        continue;
    153      
     153
    154154      SVNblame svn_blame(path_, commit->revision());
    155155      LineTypeParser parser(path_);
     
    158158      while (svn_blame.valid()) {
    159159        int lt = parser.parse(svn_blame.line());
    160         if ((lt==LineTypeParser::code || lt==LineTypeParser::comment) && 
     160        if ((lt==LineTypeParser::code || lt==LineTypeParser::comment) &&
    161161            svn_blame.revision()==commit->revision()) {
    162162          year2user_[yearrev->first].insert(name);
     
    191191      os << i->first << "\n";
    192192      os << i->second.size() << "\n";
    193       for (set<string>::const_iterator j=i->second.begin(); 
     193      for (set<string>::const_iterator j=i->second.begin();
    194194           j!=i->second.end(); ++j) {
    195195        os << *j << "\n";
  • trunk/lib/SVNproperty.cc

    r1357 r1438  
    2828#include "utility.h"
    2929
     30#include "yat/Segment.h"
     31#include "yat/utility.h"
     32
     33#include <limits>
    3034#include <string>
    3135
     
    4751
    4852
    49   void 
     53  void
    5054  SVNproperty::add(std::map<std::string, std::string>::const_iterator i,
    5155                   std::map<std::string, std::string>::const_iterator last)
    5256  {
    53     for ( ; i!=last ; ++i)
     57    for ( ; i!=last ; ++i) {
    5458      if (i->first == "svndigest:ignore")
    5559        svndigest_ignore_=true;
    56       else if (i->first == "svncopyright:ignore")
    57         svncopyright_ignore_=true;
     60      else if (i->first == "svncopyright:ignore") {
     61        add_svncopyright_ignore(i->second);
     62      }
    5863      else
    5964        if ((i->first == "svn:mime-type") &&
    6065            (svn_mime_type_is_binary(i->second.c_str())))
    6166          binary_=true;
     67    }
    6268  }
     69
     70
     71  void SVNproperty::add_svncopyright_ignore(const std::string& value)
     72  {
     73    // reset previous settings
     74    svncopyright_ignore_ = false;
     75    svncopyright_ignore_rev_.clear();
     76
     77    if (value.empty()) {
     78      svncopyright_ignore_ = true;
     79      return;
     80    }
     81
     82    std::istringstream ss(value);
     83    std::string word;
     84    // entries delimited by ';'
     85    while (getline(ss, word, ';')) {
     86      std::istringstream ss2(word);
     87      std::string first;
     88      getline(ss2, first, '-');
     89      trim(first);
     90      std::string second;
     91      bool found_dash = getline(ss2, second);
     92      yat::utility::Segment<svn_revnum_t> rev_interval;
     93      using yat::utility::convert;
     94      if (!found_dash) {
     95        rev_interval.begin() = convert<svn_revnum_t>(first);
     96        rev_interval.end() = rev_interval.begin()+1;
     97      }
     98      else {
     99        if (first.empty())
     100          rev_interval.begin() = 0;
     101        else
     102          rev_interval.begin() = convert<svn_revnum_t>(first);
     103        if (second.empty())
     104          rev_interval.end() = std::numeric_limits<svn_revnum_t>::max();
     105        else
     106          rev_interval.end() = convert<svn_revnum_t>(first)+1;
     107      }
     108      svncopyright_ignore_rev_.insert_merge(rev_interval);
     109    }
     110  }
    63111
    64112
     
    67115    return binary_;
    68116  }
    69  
     117
    70118
    71119  bool SVNproperty::svndigest_ignore(void) const
     
    80128  }
    81129
     130
     131  const yat::utility::SegmentSet<svn_revnum_t>&
     132  SVNproperty::svncopyright_ignore_rev(void) const
     133  {
     134    return svncopyright_ignore_rev_;
     135  }
     136
    82137}} // end of namespace svndigest and namespace theplu
  • trunk/lib/SVNproperty.h

    r1357 r1438  
    2424  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2525*/
     26
     27#include "yat/SegmentSet.h"
     28
     29#include <subversion-1/svn_types.h>
    2630
    2731#include <map>
     
    7579
    7680    /**
     81       \return revs that svncopyright should ignore
     82     */
     83    const yat::utility::SegmentSet<svn_revnum_t>&
     84    svncopyright_ignore_rev(void) const;
     85
     86    /**
    7787       @brief Get the list of properties for item used to creat this
    7888       SVNproperty object.
     
    90100             std::map<std::string, std::string>::const_iterator last);
    91101
     102    void add_svncopyright_ignore(const std::string& value);
     103
    92104    bool binary_;
    93105    bool svncopyright_ignore_;
    94106    bool svndigest_ignore_;
     107    yat::utility::SegmentSet<svn_revnum_t> svncopyright_ignore_rev_;
    95108  };
    96109
  • trunk/test/Makefile.am

    r1423 r1438  
    4545distributed_TESTS += copyright_cache_test.sh
    4646distributed_TESTS += error_test.sh
     47distributed_TESTS += ignore_revs_test.sh
    4748distributed_TESTS += link_root_test.sh
    4849distributed_TESTS += permission_test.sh
     
    6162
    6263# tests not yet passing are listed here
    63 XFAIL_TESTS =
     64XFAIL_TESTS = ignore_revs_test.sh
    6465
    6566noinst_HEADERS = Suite.h
  • trunk/test/remove_cache_test.sh

    r1423 r1438  
    6161echo dummie > toy_project/dir_to_be_ignored/.svndigest/foo.svncopyright-cache
    6262
    63 SVNCOPYRIGHT_run 0 --root toy_project --no-report
     63SVNCOPYRIGHT_run 0 --root toy_project
    6464test -r toy_project/bin/.svndigest/svnstat.cc.svncopyright-cache || exit_fail
    6565test -e toy_project/bin/.svndigest/foo.svncopyright-cache && exit_fail
  • trunk/yat/Makefile.am

    r1423 r1438  
    6565  cp $(srcdir)/Exception.cc.patch Fetchdir
    6666  (cd Fetchdir && patch -i Exception.cc.patch || exit 1)
     67  cp $(srcdir)/stl_utility.h.patch Fetchdir
     68  (cd Fetchdir && patch -i stl_utility.h.patch || exit 1)
    6769  @for f in $(FETCH_FILES); do \
    6870    $(MOVE_IF_CHANGE) -v Fetchdir/$$f $(srcdir)/$$f; \
  • trunk/yat/README

    r1039 r1438  
    88fetch'. Be careful doing this and particularly in sensitive branches
    99such as a stable-branch. All files are left pristine except
    10 `Exception.cc' that is modified to avoid a dependency to GSL.
     10`Exception.cc' and `stl_utility', which are modified to avoid
     11dependency to GSL and Boost, respectively.
    1112
    1213How to add a new file from yat? Add the file to 'noinst_HEADERS' or
     
    1819repository.
    1920
     21---
    2022
    2123Copyright (C) 2009, 2010 Peter Johansson
Note: See TracChangeset for help on using the changeset viewer.