Changeset 1230


Ignore:
Timestamp:
Oct 18, 2010, 6:00:23 AM (11 years ago)
Author:
Peter Johansson
Message:

refs #476. New Visitor class doing the work in svndigest binary.

Location:
branches/visitor
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/visitor/bin/svndigest.cc

    r1226 r1230  
    3434#include "lib/StatsCollection.h"
    3535#include "lib/SVN.h"
     36#include "lib/SvndigestVisitor.h"
    3637#include "lib/SVNinfo.h"
    3738#include "lib/SVNlog.h"
     
    5859                        const theplu::svndigest::Stats& stats);
    5960
    60 void write_report(const svndigestParameter& option, const std::string& repo,
    61                   const Node& tree, const StatsCollection& stats);
     61void prepare_report(const svndigestParameter& option, const std::string& repo,
     62                    const Node& tree);
    6263
    6364int main( int argc, char* argv[])
     
    113114    Directory tree(0,option.root(),"");
    114115
     116    if (option.report())
     117      prepare_report(option, repo, tree);
     118
    115119    if (option.verbose())
    116120      std::cout << "Parsing directory tree" << std::endl;
    117     const StatsCollection& stats(tree.parse(option.verbose(),
    118                                             option.ignore_cache()));
     121
     122    SvndigestVisitor visitor(option.verbose(), option.ignore_cache(),
     123                             option.report());
     124    tree.traverse(visitor);
     125    //    const StatsCollection& stats(tree.parse(option.verbose(),
     126    //                                      option.ignore_cache()));
    119127
    120128    if (option.report())
    121       write_report(option, repo, tree, stats);
     129      print_main_page(tree.name(), tree.log(), tree.stats(), tree.url());
    122130
    123131  }
     
    208216}
    209217
    210 void write_report(const svndigestParameter& option, const std::string& repo,
    211                   const Node& tree, const StatsCollection& stats)
     218void prepare_report(const svndigestParameter& option, const std::string& repo,
     219                    const Node& tree)
    212220{
    213221  std::string target_path = concatenate_path(option.targetdir(),
     
    229237  chdir(tree.name());
    230238  print_css("svndigest.css");
    231   print_main_page(tree.name(), tree.log(), stats, tree.url());
    232239  // create structure StatsType/Author/LineType
     240  /*
    233241  for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
    234242       i!=stats.stats().end(); ++i)
    235243    create_file_struct(i->first+std::string("/"), *i->second);
    236   tree.print(option.verbose());
    237 }
     244  */
     245}
  • branches/visitor/lib/Directory.cc

    r1224 r1230  
    100100  }
    101101
     102
    102103  bool Directory::dir(void) const
    103104  {
    104105    return true;
    105106  }
     107
     108
     109  void Directory::gather_stats(void)
     110  {
     111    stats_.reset();
     112    for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
     113      if (!(*i)->ignore())
     114        stats_ += (*i)->stats();
     115  }
     116
    106117
    107118  std::string Directory::href(void) const
     
    140151  {
    141152    stats_.reset();
    142     // Directories themselved give no contribution to statistics.
     153    /*
    143154    for (NodeIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
    144155      if (!(*i)->ignore())
    145156        stats_ += (*i)->parse(verbose, ignore);
     157    */
    146158    return stats_;
    147159  }
     
    150162  void Directory::print_core(const bool verbose) const
    151163  {
    152     mkdir("blame_output/" + local_path());
     164    //mkdir("blame_output/" + local_path());
    153165    // print daughter nodes
    154     for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
    155       (*i)->print(verbose);
     166    //for (NodeConstIterator i=daughters_.begin(); i!=daughters_.end(); ++i)
     167    //  (*i)->print(verbose);
    156168  }
    157169
     
    170182      outdir   += "/"+local_path();
    171183    }
    172     mkdir(outdir);
     184    mkdir_p(outdir);
    173185    if (user=="all")
    174       mkdir(imagedir);
     186      mkdir_p(imagedir);
    175187    std::string html_name = outdir+"/index.html";
    176188    std::ofstream os(html_name.c_str());
  • branches/visitor/lib/Directory.h

    r1225 r1230  
    4141  {
    4242  public:
    43 
    4443    ///
    4544    /// @brief Constructor
     
    6665    ///
    6766    bool dir(void) const;
     67
     68    /**
     69       Collect stats from daughter nodes.
     70     */
     71    void gather_stats(void);
    6872
    6973    ///
  • branches/visitor/lib/File.cc

    r1224 r1230  
    224224    std::string tmp_cache_file(cache_file+"~");
    225225    std::ofstream os(tmp_cache_file.c_str());
     226    assert(os);
    226227    stats_.print(os);
    227228    os.close();
     
    351352  void File::print_core(const bool verbose) const
    352353  {
     354    mkdir_p(directory_name(blame_output_file_name()));
    353355    std::ofstream os(blame_output_file_name().c_str());
    354356    assert(os.good());
     
    371373    std::string imagefile = stats_type+"/"+"images/"+line_type+"/"+lpath;
    372374    std::string html_name(outpath + ".html");
     375    mkdir_p(directory_name(html_name));
     376    mkdir_p(directory_name(imagefile));
    373377    std::ofstream os(html_name.c_str());
     378    assert(os);
    374379    print_header(os, name(), level_+3, user, line_type, lpath+".html",
    375380                 stats_type);
     
    413418                                           "#" + file_name(path()) + "#");
    414419    std::ofstream tmp(tmpname.c_str());
    415 
     420    assert(tmp);
    416421    using namespace std;
    417422    ifstream is(path().c_str());
  • branches/visitor/lib/Makefile.am

    r1225 r1230  
    3737  main_utility.h Node.h NodeVisitor.h \
    3838  OptionVersion.h rmdirhier.h \
    39   Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h  \
     39  Stats.h StatsCollection.h subversion_info.h \
     40  SvndigestVisitor.h SVN.h SVNblame.h \
    4041  SVNdiff.h SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h Vector.h
    4142
     
    4849  OptionVersion.cc \
    4950  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc \
    50   SVNblame.cc SVNdiff.cc SVNinfo.cc SVNlog.cc SVNproperty.cc \
     51  SVNblame.cc SVNdiff.cc SvndigestVisitor.cc SVNinfo.cc \
     52  SVNlog.cc SVNproperty.cc \
    5153  Trac.cc utility.cc Vector.cc
    5254
  • branches/visitor/lib/Node.cc

    r1222 r1230  
    221221      }
    222222    }
    223       print_core(verbose);
     223    print_core(verbose);
    224224  }
    225225
     
    327327
    328328
     329  const StatsCollection& Node::stats(void) const
     330  {
     331    return stats_;
     332  }
     333
     334
    329335  bool Node::svncopyright_ignore(void) const
    330336  {
  • branches/visitor/lib/Node.h

    r1225 r1230  
    199199    */
    200200    inline bool svndigest_ignore(void) const { return svndigest_ignore_; }
     201
     202    /**
     203     */
     204    const StatsCollection& stats(void) const;
    201205
    202206    /**
Note: See TracChangeset for help on using the changeset viewer.