Ignore:
Timestamp:
Jun 13, 2010, 7:28:19 PM (11 years ago)
Author:
Peter Johansson
Message:

merge trunk to src-highlight

Location:
branches/src-highlight
Files:
5 edited
6 copied

Legend:

Unmodified
Added
Removed
  • branches/src-highlight

  • branches/src-highlight/bin/Makefile.am

    r795 r1100  
    44
    55# Copyright (C) 2005 Jari Häkkinen
    6 # Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    7 # Copyright (C) 2007, 2008 Peter Johansson
    8 # Copyright (C) 2008 Jari Häkkinen, Peter Johansson
     6# Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     7# Copyright (C) 2010 Peter Johansson
    98#
    109# This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2322# along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2423
    25 bin_PROGRAMS = svndigest
     24bin_PROGRAMS = svndigest svncopyright
    2625
    27 svndigest_SOURCES = Parameter.cc svndigest.cc
     26svndigest_SOURCES = Parameter.cc svndigestParameter.cc svndigest.cc
     27svncopyright_SOURCES = Parameter.cc svncopyrightParameter.cc svncopyright.cc
    2828
    29 noinst_HEADERS = Parameter.h
     29noinst_HEADERS = Parameter.h svncopyrightParameter.h svndigestParameter.h
     30
     31bin_SCRIPTS = svndigest-copy-cache
     32EXTRA_DIST = svndigest-copy-cache.as
    3033
    3134LDADD = $(top_builddir)/lib/libsvndigest.a \
    32   $(top_builddir)/lib/yat/libyat.a $(SVNDIGEST_LIBS)
    33 AM_LDFLAGS = $(SVNDIGEST_LDFLAGS)
     35  $(top_builddir)/lib/yat/libyat.a $(SVN_LIBS) $(APR_LIBS) $(PLPLOT_LIBS)
     36AM_LDFLAGS = $(APR_LDFLAGS) $(SVN_LDFLAGS) $(PLPLOT_LDFLAGS)
    3437
    35 AM_CPPFLAGS = -I$(top_srcdir)/lib $(SVNDIGEST_CPPFLAGS)
    36 AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     38AM_CPPFLAGS  = -I$(top_srcdir)/lib $(DEFAULT_CPPFLAGS) \
     39  $(APR_CPPFLAGS) $(SVN_CPPFLAGS) $(PLPLOT_CPPFLAGS)
     40AM_CXXFLAGS = $(DEFAULT_CXXFLAGS)
    3741
     42##svndigest_LDADD = $(LDADD) $(PLPLOT_LIBS)
     43##svndigest_LDFLAGS = $(AM_LDFLAGS) $(PLPLOT_LDFLAGS)
     44##svndigest_CPPFLAGS  = $(AM_CPPFLAGS) $(PLPLOT_CPPFLAGS)
     45
     46.as.in:
     47  $(AUTOM4TE) -l M4sh -o $@ $(M4SH_OPTIONS) $<
     48
     49MAINTAINERCLEANFILES = svndigest-copy-cache.in
    3850
    3951clean-local:
  • branches/src-highlight/bin/Parameter.cc

    r830 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2009, 2010 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    1920  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
    2021*/
     22
     23#include <config.h> // this header file is created by configure
    2124
    2225#include "Parameter.h"
     
    3033#include "yat/OptionHelp.h"
    3134#include "yat/OptionSwitch.h"
    32 
    33 #include <config.h> // this header file is created by configure
    3435
    3536#include <cassert>
     
    4445#include <sys/stat.h>
    4546
    46 // FIXME: remove this when we require autoconf 2.64
    47 // autoconf 2.64 defines PACKAGE_URL in config.h (from AC_INIT)
    48 #ifndef PACKAGE_URL
    49 #define PACKAGE_URL "http://dev.thep.lu.se/svndigest"
    50 #endif
    51 
    5247namespace theplu {
    5348namespace svndigest {
    5449
    55   Parameter::Parameter( int argc, char *argv[])
     50  Parameter::Parameter(void)
    5651    : cmd_( std::string("Mandatory arguments to long options ") +
    5752            std::string("are mandatory for short options too.")),
    5853      config_file_(cmd_, "config-file",
    5954                   "configuration file [<ROOT>/.svndigest/config]"),
    60       copyright_(cmd_, "copyright", "update copyright statement"),
    61       force_(cmd_, "f,force",
    62              std::string("if sub-directory named <ROOT> exists in target dire")+
    63              std::string("ctory, remove sub-directory before writing results")),
    6455      generate_config_(cmd_, "g,generate-config",
    6556                       "write configuration to standard output"),
     
    6859                    std::string("ignore cache files and analyze ") +
    6960                    std::string("everything from repository")),
    70       report_(cmd_, "report", "create no HTML report", true),
    71       revisions_(cmd_, "revisions",
    72                  "use revision number as time scale instead of dates [dates]"),
    7361      root_(cmd_, "r,root",
    7462            "svn controlled directory to perform statistics on [.]"),
    75       target_(cmd_, "t,target", "output directory [.]"),
    7663      verbose_(cmd_, "v,verbose", "explain what is being done"),
    7764      version_(cmd_, "version", "print version information and exit", &verbose_)
     65  {
     66  }
     67
     68  void Parameter::parse(int argc, char* argv[])
    7869  {
    7970    init();
     
    8677    }
    8778
    88     // set default values
    89     if (!root_.present())
    90       root_.value(".");
    91 
    92     if (!target_.present())
    93       target_.value(".");
    94 
    95     if (!config_file_.present())
    96       config_file_.value(concatenate_path(root_.value(),".svndigest/config"));
     79    set_default();
    9780
    9881    // analyse arguments
     
    11497      check_existence(root_.value());
    11598      check_readable(root_.value());
    116       if (chdir(root_.value().c_str())) {
    117         std::stringstream ss;
    118         ss << "svndigest: cannot read `" << root_.value() << "': "
    119            << strerror(errno);
    120         throw yat::utility::cmd_error(ss.str());
    121       }
     99      chdir(root_.value());
    122100      root_.value(pwd());
    123       chdir(save_wd.c_str());
    124 
    125       // check target (only if we write report)
    126       if (report()) {
    127         check_existence(target_.value());
    128         check_readable(target_.value());
    129         std::string base_root = file_name(root_.value());
    130         std::string path = concatenate_path(target_.value(),base_root);
    131         if (access_rights(target_.value().c_str(), "w")) {
    132           std::stringstream ss;
    133           ss << "svndigest: cannot create directory `" << path
    134              << "': " << strerror(errno);
    135           throw yat::utility::cmd_error(ss.str());
    136         }
    137         if (node_exist(path) && !force()) {
    138           std::stringstream ss;
    139           ss << "svndigest: cannot create directory `" << path << "' "
    140              << strerror(EEXIST);
    141           throw yat::utility::cmd_error(ss.str());
    142         }
    143         if (chdir(target_.value().c_str())) {
    144           std::stringstream ss;
    145           ss << "svndigest: cannot read `" << target_.value() << "': "
    146              << strerror(errno);
    147           throw yat::utility::cmd_error(ss.str());
    148         }
    149         target_.value(pwd());
    150         chdir(save_wd.c_str());
    151       }
     101      chdir(save_wd);
    152102    }
    153103
     
    164114      check_readable(config_file_.value());
    165115      stat(config_file_.value().c_str(), &nodestat);
    166       if (!S_ISREG(nodestat.st_mode)) {
     116      if (S_ISDIR(nodestat.st_mode)) {
    167117        std::stringstream ss;
    168         ss << "svndigest: `" << config_file_.value()
    169            << "' is not a regular file";
     118        ss << cmd_.program_name() << ": `" << config_file_.value()
     119           << "' is a directory";
    170120        throw yat::utility::cmd_error(ss.str());
    171121      }
    172122    }
     123    analyse2();
    173124  }
    174125
     
    179130      return;
    180131    std::stringstream ss;
    181     ss << "svndigest: cannot stat `" << path << "': " << strerror(errno);
     132    ss << cmd_.program_name() << ": cannot stat `" << path << "': "
     133       << strerror(errno);
    182134    throw yat::utility::cmd_error(ss.str());
    183135  }
     
    189141      return;
    190142    std::stringstream ss;
    191     ss << "svndigest: cannot open `" << path << "': " << strerror(errno);
     143    ss << cmd_.program_name() << ": cannot open `" << path << "': "
     144       << strerror(errno);
    192145    throw yat::utility::cmd_error(ss.str());
    193146  }
     
    200153
    201154
    202   bool Parameter::copyright(void) const
    203   {
    204     return copyright_.present();
    205   }
    206 
    207 
    208   bool Parameter::force(void) const
    209   {
    210     return force_.present();
    211   }
    212 
    213 
    214155  bool Parameter::generate_config(void) const
    215156  {
     
    226167  void Parameter::init(void)
    227168  {
    228     // don't use argv[0] because user may rename the binary
    229     cmd_.program_name() = PACKAGE_NAME;
     169    // we like the options sorted alphabetically
     170    cmd_.sort();
    230171    config_file_.print_arg("=FILE");
    231172    root_.print_arg("=ROOT");
    232     target_.print_arg("=TARGET");
    233173    std::stringstream ss;
    234174    ss << "Report bugs to " << PACKAGE_BUGREPORT << ".\n"
    235175       << PACKAGE << " home page: <" << PACKAGE_URL << ">.\n";
    236176    help_.post_arguments() = ss.str();
    237     help_.synopsis() =
    238       "Generate statistical report for a subversion repository\n";
    239   }
    240 
    241 
    242   bool Parameter::report(void) const
    243   {
    244     return report_.value();
    245   }
    246 
    247 
    248   bool Parameter::revisions(void) const
    249   {
    250     return revisions_.present();
     177    init2();
    251178  }
    252179
     
    257184  }
    258185
    259  
    260   std::string Parameter::targetdir(void) const
    261   {
    262     return target_.value();
    263   }
    264 
    265  
     186  void Parameter::set_default(void)
     187  {
     188    if (!root_.present())
     189      root_.value(".");
     190
     191    if (!config_file_.present())
     192      config_file_.value(concatenate_path(root_.value(),".svndigest/config"));
     193
     194    set_default2();
     195  }
     196
     197
    266198  bool Parameter::verbose(void) const
    267199  {
  • branches/src-highlight/bin/Parameter.h

    r820 r1100  
    55
    66/*
    7   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    8   Copyright (C) 2007, 2008 Peter Johansson
     7  Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
     8  Copyright (C) 2009, 2010 Peter Johansson
    99
    1010  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    4747  class Parameter {
    4848  public:
    49     Parameter( int argc, char *argv[]);
     49    Parameter(void);
    5050    virtual ~Parameter(void);
     51    void parse( int argc, char *argv[]);
     52
    5153    std::string config_file(void) const;
    5254   
    53     bool copyright(void) const;
    54     bool force(void) const;
    5555    bool generate_config(void) const ;
    5656    bool ignore_cache(void) const;
    57     bool report(void) const;
    58     bool revisions(void) const;
    5957    /// @return absolute path to root directory
    6058    std::string root(void) const;
    61     /// @return absolute path to target directory
    62     std::string targetdir(void) const;
    6359    bool verbose(void) const;
    6460
    65   private:
    66     void analyse(void);
     61  protected:
     62    yat::utility::CommandLine cmd_;
     63    yat::utility::OptionHelp help_;
     64
    6765    // throw cmd_error if path doesn't exist
    6866    void check_existence(std::string path) const;
     
    7270    void check_readable(std::string path) const;
    7371
     72  private:
     73    void analyse(void);
     74    virtual void analyse2(void)=0;
    7475    void init(void);
     76    // called at end of init(void)
     77    virtual void init2(void) = 0;
     78    void set_default(void);
     79    virtual void set_default2(void)=0;
    7580
    76     yat::utility::CommandLine cmd_;
    7781    yat::utility::OptionArg<std::string> config_file_;
    78     yat::utility::OptionSwitch copyright_;
    79     yat::utility::OptionSwitch force_;
    8082    yat::utility::OptionSwitch generate_config_;
    81     yat::utility::OptionHelp help_;
    8283    yat::utility::OptionSwitch ignore_cache_;
    83     yat::utility::OptionSwitch report_;
    84     yat::utility::OptionSwitch revisions_;
    8584    yat::utility::OptionArg<std::string> root_;
    86     yat::utility::OptionArg<std::string> target_;
    8785    yat::utility::OptionSwitch verbose_;
     86  protected:
    8887    OptionVersion version_;
    8988
  • branches/src-highlight/bin/svndigest.cc

    r808 r1100  
    22
    33/*
    4   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    5   Copyright (C) 2008, 2009 Peter Johansson
     4  Copyright (C) 2006, 2007, 2008, 2009 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2010 Peter Johansson
    66
    77  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    2121*/
    2222
    23 #include "Parameter.h"
     23#include "svndigestParameter.h"
    2424
    2525#include "Configuration.h"
     
    2727#include "Directory.h"
    2828#include "first_page.h"
    29 #include "GnuplotFE.h"
     29#include "Graph.h"
    3030#include "html_utility.h"
     31#include "main_utility.h"
    3132#include "rmdirhier.h"
    3233#include "Stats.h"
     
    3839
    3940#include "yat/Exception.h"
     41#include "yat/OptionArg.h"
    4042
    4143#include <cassert>
     44#include <cstdlib>
    4245#include <iostream>
    4346#include <fstream>
     
    4750#include <unistd.h>
    4851
     52using namespace theplu;
     53using namespace svndigest;
     54void copy_option2config(const svndigestParameter&, Configuration&);
     55
    4956void create_file_struct(std::string stats_type,
    5057                        const theplu::svndigest::Stats& stats);
    5158
     59void write_report(const svndigestParameter& option, const std::string& repo,
     60                  const Node& tree, const StatsCollection& stats);
     61
    5262int main( int argc, char* argv[])
    5363{
    54   using namespace theplu;
    55   using namespace svndigest;
    5664
    5765  // Reading commandline options
    58   Parameter* option=NULL;
    59   try {
    60     option = new Parameter(argc,argv);
    61     if (option->verbose())
     66  svndigestParameter option;
     67  try {
     68    option.parse(argc,argv);
     69    if (option.verbose())
    6270      std::cout << "Done parsing parameters" << std::endl;
    6371  }
    6472  catch (yat::utility::cmd_error& e) {
    6573    std::cerr << e.what() << std::endl;
    66     exit(-1);
    67   }
    68   assert(option);
    69 
    70   // Reading configuration file
    71   Configuration& config = Configuration::instance();
    72   if (node_exist(option->config_file())) {
    73     std::ifstream is(option->config_file().c_str());
    74     if (!is.good()){
    75       is.close();
    76       std::cerr << "\nsvndigest: Cannot open config file "
    77                 << option->config_file() << std::endl;
    78       exit(-1);
     74    exit(EXIT_FAILURE);
     75  }
     76  catch (std::runtime_error& e) {
     77    std::cerr << "svndigest: " << e.what() << std::endl;
     78    return EXIT_FAILURE;
     79  }
     80
     81  try {
     82    load_config(option.config_file());
     83    copy_option2config(option, Configuration::instance());
     84    if (option.generate_config()) {
     85      std::cout << Configuration::instance();
     86      return EXIT_SUCCESS;
    7987    }
    80     try {
    81       config.load(is);
     88
     89    if (option.verbose())
     90      std::cout << "Initializing SVN singleton." << std::endl;
     91    SVN::instance(option.root());
     92
     93    // Extract repository location
     94    std::string repo=SVNinfo(option.root()).repos_root_url();
     95
     96    // build directory tree already here ... if WC is not upto date with
     97    // repo an exception is thrown. This avoids several costly
     98    // statements below and will not remove a digest tree below if a
     99    // tree already exists.
     100    if (option.verbose())
     101      std::cout << "Building directory tree" << std::endl;
     102    Directory tree(0,option.root(),"");
     103
     104    if (option.verbose())
     105      std::cout << "Parsing directory tree" << std::endl;
     106    const StatsCollection& stats(tree.parse(option.verbose(),
     107                                            option.ignore_cache()));
     108
     109    if (option.report())
     110      write_report(option, repo, tree, stats);
     111
     112    if (option.copyright()){
     113      update_copyright(tree, option.verbose());
    82114    }
    83     catch (std::runtime_error e) {
    84       std::cerr << "svndigest: invalid config file\n"
    85                 << e.what() << std::endl;
    86       exit(-1);
    87     }
    88     is.close();
     115  }
     116  catch (std::runtime_error& e) {
     117    std::cerr << "svndigest: " << e.what() << "\n";
     118    return EXIT_FAILURE;
     119  }
     120
     121  if (option.verbose())
     122    std::cout << "Done!" << std::endl;
     123  return EXIT_SUCCESS;        // normal exit
     124}
     125
     126
     127void copy_option2config(const svndigestParameter& option, Configuration& config)
     128{
     129  try {
     130    if (option.format().present())
     131      Configuration::instance().image_format(option.format().value());
     132  }
     133  catch (std::runtime_error& e) {
     134    std::stringstream ss;
     135    ss << "invalid argument `"
     136       << option.format().value() << "' for `--"
     137       << option.format().long_name() << "'\n"
     138       << e.what() << "\n"
     139       << "Try `svndigest --help' for more information.\n";
     140    throw std::runtime_error(ss.str());
     141  }
     142  try {
     143    if (option.anchor_format().present())
     144      config.image_anchor_format(option.anchor_format().value());
     145  }
     146  catch (std::runtime_error& e) {
     147    std::stringstream ss;
     148    ss << "invalid argument `"
     149       << option.anchor_format().value() << "' for `--"
     150       << option.anchor_format().long_name() << "'\n"
     151       << e.what() << "\n"
     152       << "Try `svndigest --help' for more information.\n";
     153    throw std::runtime_error(ss.str());
     154  }
     155}
     156
     157
     158void create_file_struct(std::string stats_type,
     159                        const theplu::svndigest::Stats& stats)
     160{
     161  using namespace theplu::svndigest;
     162  mkdir(stats_type);
     163  touch(stats_type+std::string("index.html"));
     164  mkdir(stats_type+std::string("all"));
     165  mkdir(stats_type+std::string("images"));
     166  touch(stats_type+std::string("all/index.html"));
     167  touch(stats_type+std::string("images/index.html"));
     168  for (std::set<std::string>::const_iterator i = stats.authors().begin();
     169       i!=stats.authors().end(); ++i) {
     170    mkdir(stats_type+*i);
     171    touch(stats_type+*i+std::string("/index.html"));
     172  }
     173}
     174
     175void remove_target(const std::string& target_path, bool verbose)
     176{
     177  if (verbose)
     178    std::cout << "Removing old target tree: " << target_path << "\n";
     179  rmdirhier(target_path);
     180  // exit if remove failed
     181  if (node_exist(target_path))
     182    throw std::runtime_error("remove failed");
     183}
     184
     185
     186void set_dates(const std::string& repo, bool verbose)
     187{
     188  if (verbose)
     189    std::cout << "retrieving dates" << std::endl;
     190  SVNlog log(repo);
     191  std::vector<std::string> dates;
     192  dates.reserve(log.commits().size());
     193  for (SVNlog::container::const_iterator iter=log.commits().begin();
     194       iter!=log.commits().end(); ++iter) {
     195    assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
     196    dates.push_back(iter->date());
     197  }
     198  // all plots uses the same dates
     199  Graph::set_dates(dates);
     200}
     201
     202void write_report(const svndigestParameter& option, const std::string& repo,
     203                  const Node& tree, const StatsCollection& stats)
     204{
     205  std::string target_path = concatenate_path(option.targetdir(),
     206                                             file_name(option.root()));
     207  // remove target if needed
     208  if (node_exist(target_path)) {
     209    assert(option.force());
     210    remove_target(target_path, option.verbose());
    89211  }
    90212 
    91   // write configuration
    92   if (option->generate_config()) {
    93     std::cout << config;
    94     exit(0);
    95   }
    96 
    97   SVN* svn=NULL;
    98   try {
    99     if (option->verbose())
    100       std::cout << "Initializing SVN singleton." << std::endl;
    101     svn=SVN::instance(option->root());
    102   }
    103   catch (SVNException e) {
    104     std::cerr << "svndigest: " << e.what() << "\n";
    105     exit(-1);
    106   }
    107 
    108   // check if target already exists and behave appropriately
    109   bool need_to_erase_target=false;
    110   std::string target_path=option->targetdir() + '/' + file_name(option->root());
    111   if (option->report()) {
    112     if (option->verbose())
    113       std::cout << "Checking target directory" << std::endl;
    114     need_to_erase_target = node_exist(target_path);
    115     if (need_to_erase_target && !option->force()) {
    116       std::cerr << "svndigest: directory `"
    117                 << target_path << "' already exists\n";
    118       exit(-1);
    119     }
    120   }
    121 
    122   // Extract repository location
    123   std::string repo;
    124   try {
    125     if (option->verbose())
    126       std::cout << "Acquiring repository information" << std::endl;
    127     repo=SVNinfo(option->root()).repos_root_url();
    128   }
    129   catch (SVNException e) {
    130     std::cerr << "\nsvndigest: " << e.what()
    131               << "\nsvndigest: Failed to determine repository for "
    132               << option->root() << '\n' << std::endl;
    133     exit(-1);
    134   }
    135 
    136   // build directory tree already here ... if WC is not upto date with
    137   // repo an exception is thrown. This avoids several costly
    138   // statements below and will not remove a digest tree below if a
    139   // tree already exists.
    140   if (option->verbose())
    141     std::cout << "Building directory tree" << std::endl;
    142   Directory* tree=NULL;
    143   try {
    144     tree = new Directory(0,option->root(),"");
    145   }
    146   catch (NodeException e) {
    147     std::cerr << "svndigest: " << e.what() << std::endl;
    148     exit(-1);
    149   }
    150   assert(tree);
    151 
    152   if (option->verbose())
    153     std::cout << "Parsing directory tree" << std::endl;
    154   StatsCollection stats(tree->parse(option->verbose(), option->ignore_cache()));
    155 
    156   if (option->report()) {
    157     // remove target if needed
    158     if (need_to_erase_target) {
    159       if (option->verbose())
    160         std::cout << "Removing old target tree: " << target_path << "\n";
    161       rmdirhier(target_path);
    162       // exit if remove failed
    163       if (node_exist(target_path)) {
    164         std::cerr << "svndigest: remove failed\n";
    165         exit(-1);
    166       }
    167     }
    168 
    169 
    170     if (option->verbose())
    171       std::cout << "Generating output" << std::endl;
    172     if (!option->revisions()) {
    173       SVNlog log(repo);
    174       std::vector<std::string> dates;
    175       dates.reserve(log.commits().size());
    176       for (SVNlog::container::const_iterator iter=log.commits().begin();
    177            iter!=log.commits().end(); ++iter) {
    178         assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
    179         dates.push_back(iter->date());
    180       }
    181       GnuplotFE::instance()->set_dates(dates);
    182     }
    183     if (chdir(option->targetdir().c_str()) ) {
    184       std::cerr << "svndigest: chdir " << option->targetdir() << " failed\n";
    185       exit(-1);
    186     }
    187     mkdir(tree->name());
    188     if (chdir(tree->name().c_str()) ) {
    189       std::cerr << "svndigest: chdir " << tree->name() << " failed\n";
    190       exit(-1);
    191     }
    192     GnuplotFE::instance()->command(std::string("cd '")+option->targetdir()+"/"
    193                                    +tree->name()+"'");
    194     print_css("svndigest.css");
    195     print_main_page(tree->name(), tree->log(), stats, tree->url());
    196     // create structure StatsType/Author/LineType
    197     for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
    198          i!=stats.stats().end(); ++i)
    199       create_file_struct(i->first+std::string("/"), *i->second);
    200     try {
    201       tree->print(option->verbose());
    202     }
    203     catch (const std::runtime_error& x) {
    204       std::cerr << "svndigest: " << x.what() << std::endl;
    205       exit(-1);
    206     }
    207   }
    208 
    209   if (option->copyright()){
    210     try {
    211       if (option->verbose())
    212         std::cout << "Updating copyright statements" << std::endl;
    213       std::map<std::string, Alias> alias(config.copyright_alias());
    214       tree->print_copyright(alias, option->verbose());
    215     }
    216     catch (const std::runtime_error& x) {
    217       std::cerr << "svndigest: " << x.what() << std::endl;
    218       exit(-1);
    219     }
    220   }
    221 
    222   if (option->verbose())
    223     std::cout << "Finalizing" << std::endl;
    224 
    225   delete tree;
    226   if (option->verbose())
    227     std::cout << "Done!" << std::endl;
    228   delete option;
    229   exit(0);        // normal exit
    230 }
    231 
    232   void create_file_struct(std::string stats_type,
    233                           const theplu::svndigest::Stats& stats)
    234   {
    235     using namespace theplu::svndigest;
    236     mkdir(stats_type);
    237     touch(stats_type+std::string("index.html"));
    238     mkdir(stats_type+std::string("all"));
    239     mkdir(stats_type+std::string("images"));
    240     touch(stats_type+std::string("all/index.html"));
    241     touch(stats_type+std::string("images/index.html"));
    242     for (std::set<std::string>::const_iterator i = stats.authors().begin();
    243          i!=stats.authors().end(); ++i) {
    244       mkdir(stats_type+*i);
    245       touch(stats_type+*i+std::string("/index.html"));
    246     }
    247   }
     213  if (!option.revisions())
     214    set_dates(repo, option.verbose());
     215
     216  chdir(option.targetdir());
     217
     218  if (option.verbose())
     219    std::cout << "Generating output" << std::endl;
     220  mkdir(tree.name());
     221  chdir(tree.name().c_str());
     222  print_css("svndigest.css");
     223  print_main_page(tree.name(), tree.log(), stats, tree.url());
     224  // create structure StatsType/Author/LineType
     225  for (std::map<std::string, Stats*>::const_iterator i(stats.stats().begin());
     226       i!=stats.stats().end(); ++i)
     227    create_file_struct(i->first+std::string("/"), *i->second);
     228  tree.print(option.verbose());
     229}
Note: See TracChangeset for help on using the changeset viewer.