Changeset 1225


Ignore:
Timestamp:
Oct 17, 2010, 10:36:40 PM (13 years ago)
Author:
Peter Johansson
Message:

refs #476. Inital version of a CopyrightVisitor?.

Location:
branches/visitor/lib
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/visitor/lib/Directory.h

    r1224 r1225  
    9999
    100100    /**
    101        Calls visitor.enter(*this), traverses daughter nodes, and calls
    102        visitor.leave(*this).
     101       Calls visitor.enter(*this). If enter returns true, daughter
     102       nodes are traverses. Finally visitor visitor.leave(*this) i called.
    103103     */
    104104    void traverse(NodeVisitor& visitor);
  • branches/visitor/lib/Makefile.am

    r1223 r1225  
    3131
    3232noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h \
    33   Colors.h Commitment.h Configuration.h css.h \
     33  Colors.h Commitment.h Configuration.h CopyrightVisitor.h css.h \
    3434  Date.h Directory.h File.h first_page.h Functor.h \
    3535  Graph.h \
     
    4242libsvndigest_a_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
    4343  ClassicStats.cc Colors.cc \
    44   Commitment.cc Configuration.cc \
     44  Commitment.cc Configuration.cc CopyrightVisitor.cc \
    4545  css.cc Date.cc Directory.cc File.cc first_page.cc\
    4646  Functor.cc Graph.cc HtmlBuf.cc HtmlStream.cc \
  • branches/visitor/lib/Node.h

    r1224 r1225  
    184184
    185185    /**
     186       \return true if svncopyright::ignore property was set
     187     */
     188    bool svncopyright_ignore(void) const;
     189
     190    /**
    186191       @brief Check if item used to create this object has been
    187192       assigned property svndigest:ignore.
     
    207212   
    208213  protected:
    209     /**
    210        \return true if svncopyright::ignore property was set
    211      */
    212     bool svncopyright_ignore(void) const;
    213 
    214214    ///
    215215    /// print path in html format (with anchors) to @a os
  • branches/visitor/lib/NodeVisitor.h

    r1223 r1225  
    3939       \brief Destructor
    4040    */
    41     virtual ~NodeVisitor(void);
     41    virtual ~NodeVisitor(void) {};
    4242
    4343    /**
     
    4646       This is a chance for the visitor to do some action before
    4747       traversing daughter nodes.
     48
     49       \return true if we should traverse daughter nodes
    4850     */
    49     virtual void enter(Directory& dir)=0;
     51    virtual bool enter(Directory& dir)=0;
    5052
    5153    /**
  • branches/visitor/lib/main_utility.cc

    r1102 r1225  
    2323
    2424#include "Configuration.h"
     25#include "CopyrightVisitor.h"
    2526#include "Node.h"
    2627#include "utility.h"
     
    5859
    5960
    60   void update_copyright(const Node& tree, bool verbose)
     61  void update_copyright(Node& tree, bool verbose)
    6162  {
    6263    if (verbose)
     
    6465    const Configuration& config = Configuration::instance();
    6566    std::map<std::string, Alias> alias(config.copyright_alias());
    66     tree.print_copyright(alias, verbose);
     67
     68    // map with last rev for every year
     69    std::map<int, svn_revnum_t> year2rev;
     70    // get log for entire project
     71    SVNlog log(SVNinfo(tree.path()).repos_root_url());
     72    typedef SVNlog::container::const_iterator LogIterator;
     73    for (LogIterator i=log.commits().begin(); i!=log.commits().end(); ++i){
     74      time_t sec = str2time(i->date());
     75      tm* timeinfo = gmtime(&sec);
     76      // ignore commits in repository not present in wc
     77      year2rev[timeinfo->tm_year] = std::min(i->revision(),
     78                                             tree.last_changed_rev());
     79    }
     80
     81    CopyrightVisitor visitor(alias, verbose, year2rev);
     82    tree.traverse(visitor);
    6783  }
    6884
  • branches/visitor/lib/main_utility.h

    r1102 r1225  
    4646     \brief update copyright statements in \a node
    4747   */
    48   void update_copyright(const Node& node, bool verbose);
     48  void update_copyright(Node& node, bool verbose);
    4949
    5050}} // end of namespace svndigest end of namespace theplu
Note: See TracChangeset for help on using the changeset viewer.