Changeset 1238


Ignore:
Timestamp:
Oct 24, 2010, 12:05:25 AM (11 years ago)
Author:
Peter Johansson
Message:

remove print_copyright from Node interface since we use traverse to traverse node tree and only need to update copyright on File

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Directory.cc

    r1236 r1238  
    272272
    273273
    274   void Directory::print_copyright(std::map<std::string, Alias>& alias,
    275                                   bool verbose,
    276                                   const std::map<int,svn_revnum_t>& y2r) const
    277   {
    278     if (!ignore() && !svncopyright_ignore()) {
    279       // print daughter nodes, i.e, this function is recursive
    280       for (NodeConstIterator i = daughters_.begin(); i!=daughters_.end(); ++i)
    281         (*i)->print_copyright(alias, verbose, y2r);
    282     }
    283   }
    284 
    285 
    286274  void Directory::traverse(NodeVisitor& visitor)
    287275  {
  • trunk/lib/Directory.h

    r1236 r1238  
    9494    std::string output_path(void) const;
    9595
    96     using Node::print_copyright;
    97     /**
    98        virtual function typically called from Node::print_copyright
    99     */
    100     void print_copyright(std::map<std::string, Alias>&, bool verbose,
    101                          const std::map<int, svn_revnum_t>&) const;
    102 
    10396    /**
    10497       Calls visitor.enter(*this). If enter returns true, daughter
  • trunk/lib/File.h

    r1234 r1238  
    7272    const StatsCollection& parse(bool verbose, bool ignore);
    7373
    74     using Node::print_copyright;
    7574    /**
    7675       @throw std::runtime_error when a file error is encountered
  • trunk/lib/Node.cc

    r1234 r1238  
    309309
    310310 
    311   void Node::print_copyright(std::map<std::string,Alias>& alias,
    312                              bool verbose) const
    313   {
    314     // map with last rev for every year
    315     std::map<int, svn_revnum_t> year2rev;
    316     // get log for entire project
    317     SVNlog log(SVNinfo(path()).repos_root_url());
    318     typedef SVNlog::container::const_iterator LogIterator;
    319     for (LogIterator i=log.commits().begin(); i!=log.commits().end(); ++i){
    320       time_t sec = str2time(i->date());
    321       tm* timeinfo = gmtime(&sec);
    322       // ignore commits in repository not present in wc
    323       year2rev[timeinfo->tm_year] = std::min(i->revision(), last_changed_rev());
    324     }
    325     print_copyright(alias, verbose, year2rev);
    326   }
    327 
    328 
    329311  const StatsCollection& Node::stats(void) const
    330312  {
  • trunk/lib/Node.h

    r1236 r1238  
    171171                              const std::string& line_type,
    172172                              const SVNlog&) const;
    173 
    174     /**
    175        creates a map from year to last rev for that year and call
    176        virtual function.
    177      */
    178     void print_copyright(std::map<std::string,Alias>&, bool) const;
    179 
    180     /**
    181        typically called from function above
    182      */
    183     virtual void print_copyright(std::map<std::string,Alias>&, bool,
    184                                  const std::map<int,svn_revnum_t>&) const=0;
    185173
    186174    /**
  • trunk/test/copyright.cc

    r1164 r1238  
    2525#include "lib/Configuration.h"
    2626#include "lib/File.h"
     27#include "lib/main_utility.h"
    2728#include "lib/SVN.h"
    2829#include "lib/SVNinfo.h"
     
    6869  // warn about missing Copyright statement only in verbose mode
    6970  if (suite.verbose()){
    70     std::string config_str("[copyright]\nmissing-copyright-warning=yes");
    71     std::stringstream ss(config_str);
     71    std::stringstream ss;
     72    ss << "[copyright]\n"
     73       << "missing-copyright-warning=yes\n"
     74       << "[copyright-alias]\n"
     75       << "jari = jh\n"
     76       << "peter = pj\n";
    7277    Configuration& config = Configuration::instance();
    7378    config.load(ss);
     
    8590  File file(0,filename,"");
    8691 
    87   suite.out() << "Get stats for file" << std::endl;
    88   file.parse(suite.verbose(), true);
    89  
    90   suite.out() << "Updating copyright statements" << std::endl;
    91   std::map<std::string, Alias> alias;
    92   alias["jari"]=Alias("jh", 1);
    93   alias["peter"]=Alias("pj", 2);
    94  
    95   file.print_copyright(alias, suite.verbose());
     92  update_copyright(file, suite.verbose(), false);
    9693
    9794  is.open(filename.c_str());
Note: See TracChangeset for help on using the changeset viewer.