Changeset 646 for branches


Ignore:
Timestamp:
Jun 4, 2008, 12:05:22 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Merged trunk changes r608:645 to replacing_gnuplot branch.

Location:
branches/replacing_gnuplot
Files:
7 deleted
30 edited
6 copied

Legend:

Unmodified
Added
Removed
  • branches/replacing_gnuplot/AUTHORS

    r519 r646  
    11$Id$
    22
    3 Copyright (C) 2005, 2006 Jari Häkkinen
     3Copyright (C) 2005, 2006, 2008 Jari Häkkinen
    44
    55Files are copyright by their respective authors. The contributions to
     
    2525
    2626
    27 This package is developed and maintained by people at the Department
    28 of Theoretical Physics at Lund University, Sweden.
    29 
    30 Jari Häkkinen
    31 Peter Johansson
     27This package is developed and maintained by Jari Häkkinen and
     28Peter Johansson.
  • branches/replacing_gnuplot/README

    r590 r646  
    1616
    1717Directory `bin` contains main program and is location for svndigest
    18 binary. Directory `build_support` contains an autotool macro that is
    19 used to find APR location. Directory `doc` contains documentation
    20 mainly in file `readme.txt`. Most of the code can be found in
    21 directory `lib`. Directory `test` contains the code for tests and the
    22 test repository (see README.developer).
     18binary. Directory `build_support` contains additional autotool macros
     19required for creating the build environment. Directory `doc` contains
     20documentation mainly in file `readme.txt`. Most of the code can be
     21found in directory `lib`. Directory `test` contains the code for tests
     22and the test repository (see README.developer).
    2323
    2424
  • branches/replacing_gnuplot/bin/Makefile.am

    r585 r646  
    3030noinst_HEADERS = Parameter.h
    3131
    32 LDADD = $(STATICFLAG) @top_builddir@/lib/libsvndigest.la
     32LDADD = @top_builddir@/lib/libsvndigest.la $(SVNDIGEST_LIBS)
     33AM_LDFLAGS = $(STATICFLAG) $(SVNDIGEST_LDFLAGS)
    3334
    34 AM_CPPFLAGS = -I@top_srcdir@/lib
     35AM_CPPFLAGS = -I@top_srcdir@/lib $(SVNDIGEST_CPPFLAGS)
     36AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     37
    3538
    3639# install versioned binary (excluding patch version)
  • branches/replacing_gnuplot/bin/Parameter.cc

    r581 r646  
    4242
    4343  Parameter::Parameter( int argc, char *argv[])
    44   {
    45     defaults();
     44    : config_file_(""), copyright_(false), force_(false),
     45      generate_config_(false), ignore_cache_(false), report_(true),
     46      revisions_(false), root_("."), root_node_("."), targetdir_("."),
     47      verbose_(false)
     48  {
    4649    for (int i=1; i<argc; ++i) {
    47       bool ok=false;
    4850      std::stringstream ss(argv[i]);
    4951      std::string myargv("");
     
    5456      if (myargv=="--config-file"){
    5557        if (value.size()) {
    56           config_file_= value;
    57           ok=true;
     58          config_file_.value()= value;
    5859        }
    5960        else if (++i<argc){
    60           config_file_= std::string(argv[i]);
    61           ok=true;
     61          config_file_.value()= std::string(argv[i]);
     62        }
     63        else {
     64          missing_argument(myargv);
    6265        }
    6366      }
    6467      else if (myargv=="--copyright"){
    65           copyright_=true;
    66           ok=true;
     68          copyright_.value()=true;
    6769      }
    6870      else if (myargv=="-f" || myargv=="--force"){
    69           force_=true;
    70           ok=true;
     71          force_.value()=true;
    7172      }
    7273      else if (myargv=="-g" || myargv=="--generate-config"){
    73           generate_config_=true;
    74           ok=true;
     74          generate_config_.value()=true;
    7575      }
    7676      else if (myargv=="-h" || myargv=="--help"){
     
    7979      }
    8080      else if (myargv=="--ignore-cache"){
    81           ignore_cache_=true;
    82           ok=true;
     81          ignore_cache_.value()=true;
    8382      }
    8483      else if (myargv=="-r" || myargv=="--root"){
    8584        if (value.size()) {
    86           root_= value;
    87           ok=true;
     85          root_.value()= value;
    8886        }
    8987        else if (++i<argc){
    90           root_= std::string(argv[i]);
    91           ok=true;
     88          root_.value()= std::string(argv[i]);
     89        }
     90        else {
     91          missing_argument(myargv);
    9292        }
    9393      }
    9494      else if (myargv=="--report") {
    95           report_=true;
    96           ok=true;
     95          report_.value()=true;
    9796      }
    9897      else if (myargv=="--no-report") {
    99           report_=false;
    100           ok=true;
     98          report_.value()=false;
    10199      }
    102100      else if (myargv=="--revisions") {
    103           revisions_=true;
    104           ok=true;
     101          revisions_.value()=true;
    105102      }
    106103      else if (myargv=="-t" || myargv=="--target"){
    107104        if (value.size()) {
    108           targetdir_= value;
    109           ok=true;
     105          targetdir_.value()= value;
    110106        }
    111107        else if (++i<argc){
    112           targetdir_= std::string(argv[i]);
    113           ok=true;
     108          targetdir_.value()= std::string(argv[i]);
     109        }
     110        else {
     111          missing_argument(myargv);
    114112        }
    115113      }
    116114      else if (myargv=="-v" || myargv=="--verbose"){
    117           verbose_=true;
    118           ok=true;
     115          verbose_.value()=true;
    119116      }
    120117      else if (myargv=="--version"){
    121         version_=true;
    122         ok=true;
     118        version();
     119        exit(0);
    123120      }
    124121      else if (myargv=="-vf" || myargv=="-fv"){
    125           verbose_=true;
    126           force_=true;
    127           ok=true;
    128       }
    129 
    130       if (!ok)
     122          verbose_.value()=true;
     123          force_.value()=true;
     124      }
     125      else {
    131126        throw std::runtime_error("svndigest: invalid option: " + myargv +
    132127                                 "\nTry `svndigest --help' for usage.");
     128      }
     129  }
     130
     131    analyse();
     132  }
     133
     134
     135  void Parameter::analyse(void)
     136  {
     137    using namespace std;
     138
     139    string workdir(pwd()); // remember current working directory (cwd).
     140
     141    if (!node_exist(root_.value()))
     142      throw runtime_error(string("svndigest: cannot stat `" + root_.value() +
     143                                 "': no such file or directory"));
     144
     145    if (access_rights(root_.value(), "r"))
     146      throw runtime_error(string("svndigest: cannot open `" + root_.value() +
     147                                 "' for reading: Permission denied"));
     148
     149    // Check whether root is directory or file
     150    struct stat nodestat;
     151    stat(root_.value().c_str(), &nodestat);
     152    if (S_ISDIR(nodestat.st_mode)) {
     153      chdir(root_.value().c_str());
     154      root_node_.value() = root_.value() = pwd();
    133155    }
    134 
    135     if (version_){
    136       version(verbose_);
    137       exit(0);
    138     }     
    139     analyse();
    140   }
    141 
    142 
    143   void Parameter::analyse(void)
    144   {
    145     using namespace std;
    146 
    147     string workdir(pwd()); // remember current working directory (cwd).
    148 
    149     bool root_ok = node_exist(root_) && !access_rights(root_, "r");
    150    
    151     if (root_ok) {
    152       // Check that root_ is a directory
    153       struct stat nodestat;
    154       stat(root_.c_str(), &nodestat);
    155       if (!S_ISDIR(nodestat.st_mode))
    156         throw runtime_error(string("svndigest: accessing `") + root_ +
    157                             "': Not a directory.");
     156    else {
     157      std::string fname = file_name(root_.value());
     158      root_.value() = directory_name(root_.value());
     159      chdir(root_.value().c_str());
     160      root_.value() = pwd();
     161      root_node_.value() = root_.value() + "/" + fname;
    158162    }
    159 
    160     // Checking that root_ exists and retrieve the absolute path to root_
    161     if (!root_ok || chdir(root_.c_str()))
    162       throw runtime_error(string("svndigest: Root directory (") + root_ +
    163                           ") access failed.");
    164     root_ = pwd();
    165 
    166      
    167163
    168164    // need to get back to cwd if relative paths are used.
     
    172168    // Checking that targetdir_ exists and retrieve the absolute path
    173169    // to targetdir_
    174     if (chdir(targetdir_.c_str()))
    175       throw runtime_error(string("svndigest: Target directory (") + targetdir_ +
    176                           ") access failed.");
    177     targetdir_ = pwd();
    178     // Checking write permissions for targetdir_
    179     if (access_rights(targetdir_,"w"))
    180       throw runtime_error(string("svndigest: No write permission on target ") +
    181                                  "directory (" + targetdir_ +").");
     170    if (report()) {
     171      if (chdir(targetdir_.value().c_str()))
     172        throw runtime_error(string("svndigest: Target directory (") +
     173                            targetdir_.value() + ") access failed.");
     174      targetdir_.value() = pwd();
     175      // Checking write permissions for targetdir_
     176      if (access_rights(targetdir_.value(),"w"))
     177        throw runtime_error(string("svndigest: No write permission on target ") +
     178                            "directory (" + targetdir_.value() +").");
     179    }
    182180
    183181    // return back to cwd
     
    191189  {
    192190    // not default
    193     if (!config_file_.empty())
    194       return config_file_;
     191    if (!config_file_.value().empty())
     192      return config_file_.value();
    195193   
    196194    // default behaviour
     
    199197
    200198
    201   void Parameter::defaults(void)
    202   {
    203     config_file_ = "";
    204     copyright_=false;
    205     force_=false;
    206     generate_config_=false;
    207     ignore_cache_=false;
    208     report_=true;
    209     revisions_=false;
    210     root_=".";
    211     targetdir_=".";
    212     verbose_=false;
    213     version_=false;
    214   }
    215 
    216 
    217   void Parameter::help(void)
    218   {
    219     defaults();
    220 
     199  void Parameter::help(void) const
     200  {
    221201    ColumnStream cs(std::cout, 1);
    222202    cs.width(0)=79;
    223203    cs.margin(0)=0;
    224204    ColumnStream cs2(std::cout, 2);
    225     cs2.width(0)=24;
     205    // Widest line should fit exactly
     206    cs2.width(0)=21;
    226207    cs2.width(1)=52;
    227208    cs2.margin(0)=2;
     209    // Gnits standard suggest three characters gap between option and description
     210    cs2.margin(1)=3;
    228211
    229212    std::cout << "Usage: svndigest [OPTION]...\n"
     
    235218       << "short options too.\n";
    236219
    237     cs2  << "    --copyright\tupdate copyright statement\n"
    238          << "    --config-file=ARG\tconfiguration file "
     220    cs2  << "    --config-file=ARG\tconfiguration file "
    239221         << "[<ROOT>/.svndigest/config]\n"
     222         << "    --copyright\tupdate copyright statement\n"
    240223         << "-f, --force\tif sub-directory named <ROOT> exists in "
    241224         << "target directory, remove sub-directory before writing results\n"
     
    243226         << "to standard output and exit\n"
    244227         << "-h, --help\tdisplay this help and exit\n"
    245          << "    --ignore-cache\tIgnore cache files and analyze "
     228         << "    --ignore-cache\tignore cache files and analyze "
    246229         << "everything from repository\n"
    247          << "    --no-report\tCreate no HTML report\n"
    248          << "    --revisions\tUse revision numbers as time scale "
     230         << "    --no-report\tcreate no HTML report\n"
     231         << "    --revisions\tuse revision numbers as time scale "
    249232         << "instead of dates [dates]\n"
    250233         << "-r, --root=ROOT\tsvn controlled directory to perform "
    251          << "statistics calculation on [" << root_ << "]\n"
    252          << "-t, --target=TARGET\toutput directory [" << targetdir_ << "]\n"
     234         << "statistics calculation on [" << root_.default_value() << "]\n"
     235         << "-t, --target=TARGET\toutput directory ["
     236         << targetdir_.default_value() << "]\n"
    253237         << "-v, --verbose\texplain what is being done\n"
    254238         << "    --version\tprint version information and exit\n";
     
    259243
    260244
     245  void Parameter::missing_argument(std::string opt) const
     246  {
     247    if (opt.size()>0 && opt[0]=='-')
     248      opt = opt.substr(1);
     249    if (opt.size()>0 && opt[0]=='-')
     250      opt = opt.substr(1);
     251    std::stringstream ss;
     252    ss << "svndigest: option requires an argument -- " << opt << "\n"
     253       << "Try `svndigest --help' for usage.";
     254    throw std::runtime_error(ss.str());
     255  }
     256
    261257  void Parameter::version(bool verbose) const
    262258  {
    263259    ColumnStream cs(std::cout, 1);
    264260    cs.width(0)=79;
    265     cs << PACKAGE_STRING;
    266     cs << " (";
    267     if (DEV_BUILD)
    268       cs << "r" << svn_revision() << " ";
    269     cs << "compiled " << __DATE__ ", " << __TIME__ << ")\n";
    270    
     261    cs << PACKAGE_STRING << version_string() << "\n";
    271262    cs << "\nCopyright (C) " << svn_year()
    272263       << " Jari H\u00E4kkinen and Peter Johansson.\n"
  • branches/replacing_gnuplot/bin/Parameter.h

    r540 r646  
    2626*/
    2727
     28#include "Option.h"
     29
    2830#include <map>
    2931#include <string>
     
    3739    Parameter( int argc, char *argv[]);
    3840    std::string config_file(void) const;
    39     inline bool copyright(void) const { return copyright_; }
     41    inline bool copyright(void) const { return copyright_.value(); }
    4042    /// @todo
    41     inline bool force(void) const { return force_; }
    42     inline bool generate_config(void) const { return generate_config_; }
    43     inline bool ignore_cache(void) const { return ignore_cache_; }
    44     inline bool report(void) const { return report_; }
    45     inline bool revisions(void) const { return revisions_; }
     43    inline bool force(void) const { return force_.value(); }
     44    inline bool generate_config(void) const { return generate_config_.value(); }
     45    // Until we fix caching (#313) ignore caching
     46    //inline bool ignore_cache(void) const { return ignore_cache_.value(); }
     47    inline bool ignore_cache(void) const { return true; }
     48    inline bool report(void) const { return report_.value(); }
     49    inline bool revisions(void) const { return revisions_.value(); }
    4650    /// @return absolute path to root directory
    47     inline const std::string& root(void) const { return root_; }
     51    inline const std::string& root(void) const { return root_.value(); }
     52    /// @return absolute path to root node
     53    inline const std::string& root_node(void) const {return root_node_.value();}
    4854    /// @return absolute path to target directory
    49     inline const std::string& targetdir(void) const { return targetdir_; }
    50     inline bool verbose(void) const { return verbose_; }
     55    inline const std::string& targetdir(void) const
     56    { return targetdir_.value(); }
     57    inline bool verbose(void) const { return verbose_.value(); }
    5158
    5259  private:
    5360    void analyse(void);
    54     void defaults(void);
    55     void help(void);
     61    void help(void) const;
     62    void missing_argument(std::string opt) const;
    5663    void version(bool=false) const;
    5764
    58     std::string config_file_;
    59     bool copyright_;
    60     bool force_;
    61     bool generate_config_;
    62     bool ignore_cache_;
    63     bool report_;
    64     bool revisions_;
    65     std::string root_;
    66     std::string targetdir_;
    67     bool verbose_;
    68     bool version_;
     65    Option<std::string> config_file_;
     66    Option<bool> copyright_;
     67    Option<bool> force_;
     68    Option<bool> generate_config_;
     69    Option<bool> ignore_cache_;
     70    Option<bool> report_;
     71    Option<bool> revisions_;
     72    Option<std::string> root_;
     73    Option<std::string> root_node_;
     74    Option<std::string> targetdir_;
     75    Option<bool> verbose_;
    6976  };
    7077
  • branches/replacing_gnuplot/bin/svndigest.cc

    r579 r646  
    160160    if (option->verbose())
    161161      std::cout << "Generating output" << std::endl;
    162     if (!option->revisions())
    163       GnuplotFE::instance()->set_dates(SVNlog(repo).date());
     162    if (!option->revisions()) {
     163      SVNlog log(repo);
     164      std::vector<std::string> dates;
     165      dates.reserve(log.commits().size());
     166      for (size_t i=0; i<log.commits().size(); ++i) {
     167        assert(static_cast<svn_revnum_t>(i)==log.commits()[i].revision());
     168        dates.push_back(log.commits()[i].date());
     169      }
     170      GnuplotFE::instance()->set_dates(dates);
     171    }
    164172    chdir(option->targetdir().c_str());
    165173    mkdir(tree->name());
  • branches/replacing_gnuplot/build_support/move-if-change

    • Property svn:eol-style set to native
  • branches/replacing_gnuplot/build_support/version.m4

    r585 r646  
    11## $Id$
    22#
    3 # Copyright (C) 2008 Peter Johansson
     3# Copyright (C) 2008 Jari Häkkinen, Peter Johansson
    44#
    55# This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    3131m4_define([PATCH_VERSION], [0])
    3232
    33 # DEV_BUILD - When rolling a tarball we set this to `false'. In
     33# SVNDIGEST_DEV_BUILD - When rolling a tarball we set this to `false'. In
    3434# repository value remains `true'.
    3535m4_define([SVNDIGEST_DEV_BUILD], [true])
     
    4545m4_define([SVNDIGEST_VERSION], m4_if(PATCH_VERSION,[0], SVNDIGEST_VERSION,
    4646                                  SVNDIGEST_VERSION.PATCH_VERSION))
    47 m4_define([SVNDIGEST_VERSION], m4_if(DEV_BUILD,[true], [pre]SVNDIGEST_VERSION,
    48                                   SVNDIGEST_VERSION))
     47m4_define([SVNDIGEST_VERSION], m4_if(SVNDIGEST_DEV_BUILD,
     48                                    [true], [pre]SVNDIGEST_VERSION,
     49                                    SVNDIGEST_VERSION))
    4950
  • branches/replacing_gnuplot/configure.ac

    r606 r646  
    7676AC_CHECK_PROG([GNUPLOT],[gnuplot],[ok])
    7777
     78# Save FLAGS
     79SAVE_CPPFLAGS="$CPPFLAGS"
     80SAVE_CXXFLAGS="$CXXFLAGS"
     81SAVE_LDFLAGS="$LDFLAGS"
     82SAVE_LIBS="$LIBS"
     83
    7884# -Wno-long-long is needed to suppress compiler diagnostics regarding
    7985# using extension beyond the C++ standard (usage of non C++ standard
    8086# 'long long' types).
    81 CXXFLAGS="$CXXFLAGS -Wall -pedantic -Wno-long-long"
     87SD_CXXFLAGS="$SD_CXXFLAGS-Wall -pedantic -Wno-long-long"
    8288AC_TYPE_LONG_LONG_INT()
    8389
    8490AC_ARG_ENABLE(debug,
    8591  [AS_HELP_STRING([--enable-debug],[turn on debug options and code])],
    86   [CXXFLAGS="$CXXFLAGS -g -O"],
    87   [CPPFLAGS="$CPPFLAGS -DNDEBUG" CXXFLAGS="$CXXFLAGS -O3"])
     92  [SD_CXXFLAGS="$SD_CXXFLAGS -g -O"],
     93  [SD_CPPFLAGS="-DNDEBUG" SD_CXXFLAGS="$SD_CXXFLAGS -O3"])
    8894
    8995# optionally prepare for building static libraries.
     
    98104    # Keychain on Mac OSX. In consequence the below
    99105    # frameworks are needed for succesful static builds.
    100     LIBS="$LIBS -framework Security"
    101     LIBS="$LIBS -framework CoreFoundation"
    102     LIBS="$LIBS -framework CoreServices"
     106    SD_LIBS="$SD_LIBS -framework Security"
     107    SD_LIBS="$SD_LIBS -framework CoreFoundation"
     108    SD_LIBS="$SD_LIBS -framework CoreServices"
    103109    ;;
    104110  esac
     
    118124# AC_SEARCH_LIBS([apr_allocator_create],[apr-0],,apr_found="no") but
    119125# apr-0 must be prior knowledge.
    120 sinclude(./build_support/find_apr.m4)
     126m4_sinclude(./build_support/find_apr.m4)
    121127APR_FIND_APR(,,1,[1 0])
    122128if test "$apr_found" = "yes" ; then
    123     LDFLAGS="`$apr_config --link-ld` $LDFLAGS"
    124     CPPFLAGS="`$apr_config --includes` $CPPFLAGS"
    125     AC_CHECK_HEADER([apr_allocator.h],,apr_found="no")
     129    SD_LDFLAGS="`$apr_config --link-ld` $SD_LDFLAGS"
     130    SD_CPPFLAGS="`$apr_config --includes --cppflags` $SD_CPPFLAGS"
    126131fi
    127132
     
    130135AC_ARG_WITH(svn,
    131136  [AS_HELP_STRING([--with-svn=DIR],[prefix for svn developer files [[PREFIX]]])],
    132   [ LDFLAGS="-L$withval/lib $LDFLAGS" CPPFLAGS="-I$withval/include $CPPFLAGS"])
     137  [ SD_LDFLAGS="-L$withval/lib $SD_LDFLAGS"
     138    SD_CPPFLAGS="-I$withval/include $SD_CPPFLAGS"])
     139
     140
     141# Use SD_*FLAGS in tests
     142CPPFLAGS="$SD_CPPFLAGS $CPPFLAGS"
     143CXXFLAGS="$SD_CXXFLAGS $CXXFLAGS"
     144LDFLAGS="$SD_LDFLAGS $LDFLAGS"
     145LIBS="$SD_LIBS $LIBS"
     146
     147AC_CHECK_HEADER([apr_allocator.h],,apr_found="no")
    133148AC_CHECK_HEADER([subversion-1/svn_types.h],,svn_found="no")
    134149# The library checks below may match shared libs even when
     
    136151# pose any problems since in a properly installed system the shared
    137152# and static libraries should be the same.
    138 AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],,svn_found="no")
    139 AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1],,svn_found="no")
    140 AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1],,svn_found="no")
    141 AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],,svn_found="no")
    142 AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],,svn_found="no")
    143 
     153AC_SEARCH_LIBS([svn_cmdline_setup_auth_baton],[svn_subr-1],
     154               [SD_LIBS="-lsvn_subr-1 $SD_LIBS"],svn_found="no")
     155AC_SEARCH_LIBS([svn_ra_initialize],[svn_ra-1],
     156               [SD_LIBS="-lsvn_ra-1 $SD_LIBS"],svn_found="no")
     157AC_SEARCH_LIBS([svn_wc_adm_open3],[svn_wc-1],
     158               [SD_LIBS="-lsvn_wc-1 $SD_LIBS"],svn_found="no")
     159AC_SEARCH_LIBS([svn_diff_file_options_create],[svn_diff-1],
     160               [SD_LIBS="-lsvn_diff-1 $SD_LIBS"],svn_found="no")
     161AC_SEARCH_LIBS([svn_client_log3],[svn_client-1],
     162               [SD_LIBS="-lsvn_client-1 $SD_LIBS"],svn_found="no")
     163
     164# Export flags
     165AC_SUBST([SVNDIGEST_CPPFLAGS], $SD_CPPFLAGS)
     166AC_SUBST([SVNDIGEST_CXXFLAGS], $SD_CXXFLAGS)
     167AC_SUBST([SVNDIGEST_LDFLAGS], $SD_LDFLAGS)
     168AC_SUBST([SVNDIGEST_LIBS], $SD_LIBS)
     169
     170# Reset FLAGS
     171CPPFLAGS="$SAVE_CPPFLAGS"
     172CXXFLAGS="$SAVE_CXXFLAGS"
     173LDFLAGS="$SAVE_LDFLAGS"
     174LIBS="$SAVE_LIBS"
    144175
    145176# check if svnversion is installed
     
    147178AC_PATH_PROG(SVNVERSION, svnversion, have_svnversion="no")
    148179
     180# checking if we build in a subversion WC
    149181wc_found="no";
    150182if (test $have_svnversion != "no" &&
     
    155187AC_CHECK_FILE("$srcdir/lib/subversion_info.cc",info_found="yes",info_found="no")
    156188
    157 # Checking that a release (non-dev) has no pre in VERSION
     189# checking that DEV_BUILD is set to false at time of release
    158190# Failure should be captured by distcheck
    159 if (test "$wc_found" = "no" && test "$DEV_BUILD" = "yes") ; then
    160    AC_MSG_ERROR([Incorrect version number: $VERSION
    161                  Version number of an official release should have format
    162                  MAJOR.MINOR or MAJOR.MINOR.PATCH])
    163 fi
     191if (test "$wc_found" = "no" && test "$SVNDIGEST_DEV_BUILD" = "true") ; then
     192  AC_MSG_ERROR([Incorrect version:
     193               [SVNDIGEST_DEV_BUILD] is set to SVNDIGEST_DEV_BUILD.
     194         [SVNDIGEST_DEV_BUILD] should be set to false at time of release.
     195               Please, update version.m4.])
     196fi
     197
    164198
    165199# devel version should have svn WC and SVNVERSION installed
     
    249283AC_MSG_NOTICE([   The following flags and libs will be used:])
    250284AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
    251 AC_MSG_NOTICE([    Compiler:           CXX=\"$CXX\"])
    252 AC_MSG_NOTICE([    Preprocessor flags: CPPFLAGS=\"$CPPFLAGS\"])
    253 AC_MSG_NOTICE([    C++ flags:          CXXFLAGS=\"$CXXFLAGS\"])
    254 AC_MSG_NOTICE([    Linker flags:       LDFLAGS=\"$LDFLAGS\"])
    255 AC_MSG_NOTICE([    LIBS:               LIBS=\"$LIBS\"])
     285AC_MSG_NOTICE([    Compiler:           $CXX])
     286AC_MSG_NOTICE([    Preprocessor flags: $SD_CPPFLAGS $CPPFLAGS])
     287AC_MSG_NOTICE([    C++ flags:          $SD_CXXFLAGS $CXXFLAGS])
     288AC_MSG_NOTICE([    Linker flags:       $SD_LDFLAGS $LDFLAGS])
     289AC_MSG_NOTICE([    LIBS:               $SD_LIBS $LIBS])
    256290AC_MSG_NOTICE([   +++++++++++++++++++++++++++++++++++++++++++++++])
    257291AC_MSG_NOTICE([])
  • branches/replacing_gnuplot/lib/AddStats.cc

    r552 r646  
    6060    typedef std::set<svn_revnum_t> RevSet;
    6161    RevSet revs;
    62     std::copy(log.revision().begin(), log.revision().end(),
    63               std::inserter(revs, revs.begin()));
     62    std::transform(log.commits().begin(), log.commits().end(),
     63                   std::inserter(revs, revs.begin()), GetRevision());
    6464    for (RevSet::iterator rev_iter=revs.begin();rev_iter!=revs.end();++rev_iter){
    6565      SVNblame svn_blame(path, *rev_iter);
  • branches/replacing_gnuplot/lib/BlameStats.cc

    r589 r646  
    8282    typedef std::set<svn_revnum_t> RevSet;
    8383    RevSet revs;
    84     std::copy(log.revision().begin(), log.revision().end(),
    85               std::inserter(revs, revs.begin()));
     84    std::transform(log.commits().begin(), log.commits().end(),
     85                   std::inserter(revs, revs.begin()), GetRevision());
    8686    for (RevSet::iterator rev_iter=revs.begin();rev_iter!=revs.end();++rev_iter){
    8787      SVNblame svn_blame(path, *rev_iter);
  • branches/replacing_gnuplot/lib/ColumnStream.h

    r519 r646  
    66/*
    77  Copyright (C) 2007 Peter Johansson
     8  Copyright (C) 2008 Jari Häkkinen
    89
    910  This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    2425  02111-1307, USA.
    2526*/
    26 #include <fstream>
     27
     28#include <iosfwd>
    2729#include <sstream>
    2830#include <vector>
  • branches/replacing_gnuplot/lib/Commitment.cc

    r519 r646  
    3636
    3737  Commitment::Commitment(std::string author, std::string date,
    38                          std::string msg, size_t rev)
     38                         std::string msg, svn_revnum_t rev)
    3939    : author_(author), date_(date), msg_(msg), rev_(rev)
    4040  {
  • branches/replacing_gnuplot/lib/Commitment.h

    r519 r646  
    2727#include <string>
    2828
     29#include <subversion-1/svn_types.h>
     30
    2931namespace theplu {
    3032namespace svndigest {
     
    4850    */
    4951    Commitment(std::string author, std::string date, std::string msg,
    50                size_t rev);
     52               svn_revnum_t rev);
    5153
    5254    /**
    5355       \return Author
    5456    */
    55     inline std::string author(void) const { return author_; }
     57    inline const std::string& author(void) const { return author_; }
    5658
    5759    /**
    5860       \return Date
    5961    */
    60     inline std::string date(void) const { return date_; }
     62    inline const std::string& date(void) const { return date_; }
    6163
    6264    /**
    6365       \return Message
    6466    */
    65     inline std::string message(void) const { return msg_; }
     67    inline const std::string& message(void) const { return msg_; }
    6668
    6769    /**
    6870       \return Revision
    6971    */
    70     inline size_t revision(void) const { return rev_; }
     72    inline svn_revnum_t revision(void) const { return rev_; }
    7173
    7274  private:
     
    8082    std::string date_;
    8183    std::string msg_;
    82     size_t rev_;
     84    svn_revnum_t rev_;
    8385
    8486  };
     
    9193  };
    9294
     95  struct GetAuthor
     96  {
     97    inline const std::string& operator()(const Commitment& commit) const
     98    { return commit.author(); }
     99  };
     100
     101  struct GetRevision
     102  {
     103    inline svn_revnum_t operator()(const Commitment& commit) const
     104    { return commit.revision(); }
     105  };
     106
    93107}} // end of namespace svndigest and namespace theplu
    94108
  • branches/replacing_gnuplot/lib/File.cc

    r597 r646  
    4141#include <iostream>
    4242#include <map>
     43#include <stdexcept>
    4344#include <string>
    4445#include <sys/stat.h>
     
    6667    const Stats& stats = stats_["add"];
    6768   
    68 
    69     for (LogIterator i=log.begin(); i<log.end(); ++i){
     69    typedef std::vector<Commitment>::iterator LogIterator;
     70    for (LogIterator i=log.commits().begin(); i<log.commits().end(); ++i){
    7071      if (i->revision() &&
    7172          (stats(LineTypeParser::code, i->author(), i->revision()) >
     
    183184    std::string cache_dir = directory_name(path()) + std::string(".svndigest/");
    184185    std::string cache_file = cache_dir + name()+std::string(".svndigest-cache");
    185     if (node_exist(cache_file)){
     186    if (!ignore && node_exist(cache_file)){
    186187      std::ifstream is(cache_file.c_str());
    187188      if (stats_.load_cache(is)){
     
    190191      is.close();
    191192    }
    192     else
     193    else {
    193194      stats_.parse(path_);
     195    }
    194196    if (!node_exist(cache_dir))
    195197      mkdir(cache_dir);
     
    262264      if (*line_type==LineTypeParser::other)
    263265        os << "line-other";
    264       else if (*line_type==LineTypeParser::comment)
     266      else if (*line_type==LineTypeParser::comment ||
     267               *line_type==LineTypeParser::copyright)       
    265268        os << "line-comment";
    266       else
     269      else if (*line_type==LineTypeParser::code)
    267270        os << "line-code";
     271      else {
     272        std::string msg="File::print_blame(): unexpected line type found";
     273        throw std::runtime_error(msg);
     274      }
    268275      os << "\">" << blame.line_no()+1
    269276         << "</td>\n<td>";
     
    313320                        const SVNlog& log) const
    314321  {
    315     std::string outpath = stats_type+"/"+user+"/"+line_type+"/"+local_path();
     322    std::string lpath = local_path();
     323    if (lpath.empty())
     324      lpath = "index";
     325    std::string outpath = stats_type+"/"+user+"/"+line_type+"/"+lpath;
    316326    std::string imagefile = stats_type+"/"+"images/"+line_type+"/"+
    317       local_path_+".png";
     327      lpath+".png";
    318328    std::string html_name(outpath + ".html");
    319329    std::ofstream os(html_name.c_str());
    320     print_header(os, name(), level_+3, user, line_type, local_path()+".html",
     330    print_header(os, name(), level_+3, user, line_type, lpath+".html",
    321331                 stats_type);
    322332    path_anchor(os);
    323 
    324333    os << "<p class=\"plot\">\n<img src='";
    325334    for (size_t i=0; i<level_; ++i)
  • branches/replacing_gnuplot/lib/Makefile.am

    r606 r646  
    2424# 02111-1307, USA.
    2525
     26AM_CPPFLAGS = $(SVNDIGEST_CPPFLAGS)
     27AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
     28
    2629noinst_LTLIBRARIES = libsvndigest.la
    2730
     
    3033  Date.h Directory.h File.h first_page.h Functor.h Gnuplot.h GnuplotFE.h \
    3134  HtmlBuf.h HtmlStream.h html_utility.h LineTypeParser.h \
    32   LogIterator.h Node.h rmdirhier.h \
     35  Node.h Option.h rmdirhier.h \
    3336  Stats.h StatsCollection.h subversion_info.h SVN.h SVNblame.h  \
    3437  SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h
     
    3942  css.cc Date.cc Directory.cc File.cc first_page.cc\
    4043  Functor.cc Gnuplot.cc GnuplotFE.cc  HtmlBuf.cc HtmlStream.cc \
    41   html_utility.cc LineTypeParser.cc LogIterator.cc Node.cc \
     44  html_utility.cc LineTypeParser.cc Node.cc \
    4245  rmdirhier.cc Stats.cc StatsCollection.cc subversion_info.cc SVN.cc        \
    4346  SVNblame.cc SVNinfo.cc SVNlog.cc SVNproperty.cc Trac.cc utility.cc
  • branches/replacing_gnuplot/lib/Node.cc

    r589 r646  
    7676    if (ignore())
    7777      return svninfo_.last_changed_author();
    78     assert(log().author().size());
    79     return log().author().back();
     78    assert(log().commits().size());
     79    return log().commits().back().author();
    8080  }
    8181
     
    143143    if (ignore())
    144144      return svninfo_.last_changed_rev();
    145     assert(log().revision().size());
    146     return log().revision().back();
     145    assert(log().commits().size());
     146    return log().commits().back().revision();
    147147  }
    148148
  • branches/replacing_gnuplot/lib/SVN.cc

    r579 r646  
    3030#include <vector>
    3131
    32 #include <iostream>
     32#include <cassert>
    3333
    3434#include <apr_allocator.h>
  • branches/replacing_gnuplot/lib/SVNlog.cc

    r519 r646  
    2525
    2626#include "Commitment.h"
    27 #include "LogIterator.h"
    2827#include "SVN.h"
    2928
     
    3938  SVNlog::SVNlog(void)
    4039  {
    41     assert(date().empty());
    42     assert(author().empty());
    43     assert(revision().empty());
    44     assert(message().empty());
    4540  }
    4641
     
    5045    SVN::instance()->client_log(path, log_message_receiver,
    5146                                static_cast<void*>(&lb_));
    52     assert(date().size()==author().size());
    53     assert(date().size()==revision().size());
    54     assert(date().size()==message().size());
    5547  }
    5648
     
    6153
    6254 
    63   LogIterator SVNlog::begin() const
     55  bool SVNlog::exist(std::string name) const
    6456  {
    65     return LogIterator(*this, 0);
     57   
     58    std::vector<Commitment>::const_reverse_iterator iter = commits().rbegin();
     59    for ( ; iter!= commits().rend(); ++iter)
     60      if (iter->author() == name)
     61        return true;
     62    return false;
    6663  }
    6764
    6865
    69   LogIterator SVNlog::end() const
     66  const Commitment& SVNlog::latest_commit(void) const
    7067  {
    71     return LogIterator(*this, revision().size());
     68    return commits().back();
    7269  }
    7370
    7471
    75   bool SVNlog::exist(std::string name) const
     72  const Commitment& SVNlog::latest_commit(std::string name) const
    7673  {
    77     std::vector<std::string>::const_reverse_iterator iter =
    78       find(author().rbegin(), author().rend(), name);
    79     return iter!=author().rend();
    80   }
    81 
    82 
    83   Commitment SVNlog::latest_commit(void) const
    84   {
    85     return Commitment(author().back(), date().back(),
    86                       message().back(), revision().back());
    87                                              
    88   }
    89 
    90 
    91   Commitment SVNlog::latest_commit(std::string name) const
    92   {
    93     std::vector<std::string>::const_reverse_iterator iter =
    94       find(author().rbegin(), author().rend(), name);
    95     size_t dist(std::distance(iter, author().rend()));
    96     if (!dist) {
    97       Commitment c;
    98       assert(false);
    99       return c;
    100     }
    101     return Commitment(author()[dist-1], date()[dist-1],
    102                       message()[dist-1], revision()[dist-1]);
    103                                              
    104   }
    105 
    106 
    107   void SVNlog::push_back(const Commitment& c)
    108   {
    109     lb_.authors.push_back(c.author());
    110     lb_.commit_dates.push_back(c.date());
    111     lb_.msg.push_back(c.message());
    112     lb_.rev.push_back(c.revision());
    113   }
    114 
    115 
    116   void SVNlog::reserve(size_t i)
    117   {
    118     lb_.authors.reserve(i);
    119     lb_.commit_dates.reserve(i);
    120     lb_.msg.reserve(i);
    121     lb_.rev.reserve(i);
     74    std::vector<Commitment>::const_reverse_iterator iter = commits().rbegin();
     75    for ( ; iter!= commits().rend(); ++iter)
     76      if (iter->author() == name)
     77        return *iter;
     78    assert(false);
    12279  }
    12380
     
    13087  {
    13188    struct log_receiver_baton *lb=static_cast<struct log_receiver_baton*>(baton);
    132     if (date && date[0])
    133       lb->commit_dates.push_back(date);
    134     else
     89    if (!date || !date[0])
    13590      throw SVNException("No date defined for revision: " + rev);
     91    std::string a;
    13692    if (author && author[0])
    137       lb->authors.push_back(author);
    138     else
    139       lb->authors.push_back("");
    140     lb->rev.push_back(rev);
     93      a=author;
     94    std::string message;
    14195    if (msg)
    142       lb->msg.push_back(std::string(msg));
    143     else
    144       lb->msg.push_back(std::string(""));
     96      message = msg;
     97    lb->commits.push_back(Commitment(a, date, message, rev));
    14598    return SVN_NO_ERROR;
    14699  }
     
    149102  void SVNlog::swap(SVNlog& rhs)
    150103  {
    151     lb_.authors.swap(rhs.lb_.authors);
    152     lb_.commit_dates.swap(rhs.lb_.commit_dates);
    153     lb_.msg.swap(rhs.lb_.msg);
    154     lb_.rev.swap(rhs.lb_.rev);
     104    lb_.commits.swap(rhs.lb_.commits);
    155105  }
    156106
     
    159109  {
    160110    SVNlog log;
    161     LogIterator lhs_iter(lhs.begin());
    162     LogIterator rhs_iter(rhs.begin());
    163     while(lhs_iter<lhs.end() && rhs_iter<rhs.end()) {
     111    std::vector<Commitment>::iterator lhs_iter=lhs.commits().begin();
     112    std::vector<Commitment>::const_iterator rhs_iter=rhs.commits().begin();
     113    while(lhs_iter<lhs.commits().end() && rhs_iter<rhs.commits().end()) {
    164114      if (lhs_iter->revision() < rhs_iter->revision()) {
    165115       
    166         log.push_back(*lhs_iter);
     116        log.commits().push_back(*lhs_iter);
    167117        ++lhs_iter;
    168118      }
    169119      else if (rhs_iter->revision()<lhs_iter->revision()) {
    170         log.push_back(*rhs_iter);
     120        log.commits().push_back(*rhs_iter);
    171121        ++rhs_iter;
    172122      }
    173123      else {
    174         log.push_back(*lhs_iter);
     124        log.commits().push_back(*lhs_iter);
    175125        ++lhs_iter;
    176126        ++rhs_iter;
    177127      }
    178128    }
    179     while(lhs_iter<lhs.end()) {
    180         log.push_back(*lhs_iter);
    181         ++lhs_iter;
     129    while(lhs_iter<lhs.commits().end()) {
     130      log.commits().push_back(*lhs_iter);
     131      ++lhs_iter;
    182132    }
    183     while(rhs_iter<rhs.end()) {
    184         log.push_back(*rhs_iter);
    185         ++rhs_iter;
     133    while(rhs_iter<rhs.commits().end()) {
     134      log.commits().push_back(*rhs_iter);
     135      ++rhs_iter;
    186136    }
    187137    lhs.swap(log);
  • branches/replacing_gnuplot/lib/SVNlog.h

    r519 r646  
    2828
    2929#include "Commitment.h"
    30 #include "LogIterator.h"
    3130
    3231#include <string>
     
    4342     The SVNlog class is a utility class for taking care of 'svn
    4443     log' information. An 'svn log' is performed on an item, the
    45      log information for each revision is stored in vectors.
     44     log information for each revision is a vector<Commitment>.
    4645  */
    4746  class SVNlog {
    4847  public:
    49 
    5048    /**
    5149       Default constructor. Creates empty log.
     
    6765
    6866    /**
    69        \return Authors
     67       \return Commitments
    7068    */
    71     inline const std::vector<std::string>& author(void) const
    72     { return lb_.authors; }
     69    inline const std::vector<Commitment>& commits(void) const
     70    { return lb_.commits; }
    7371
    7472    /**
    75      */
    76     LogIterator begin(void) const;
    77 
    78     /**
    79        \return Dates
     73       \return Commitments
    8074    */
    81     inline const std::vector<std::string>& date(void) const
    82     { return lb_.commit_dates; }
    83 
    84     /**
    85      */
    86     LogIterator end(void) const;
     75    inline std::vector<Commitment>& commits(void)
     76    { return lb_.commits; }
    8777
    8878    /**
     
    9282
    9383    /**
    94        \return Messages
    95     */
    96     inline const std::vector<std::string>& message(void) const
    97     { return lb_.msg; }
    98 
    99     /**
    10084       \return Latest commit
    10185    */
    102     Commitment latest_commit(void) const;
     86    const Commitment& latest_commit(void) const;
    10387
    10488    /**
     
    10690       empty Commitment (default constructor) is returned.
    10791    */
    108     Commitment latest_commit(std::string author) const;
    109 
    110     /**
    111        \return Revisions
    112     */
    113     inline const std::vector<size_t>& revision(void) const
    114     { return lb_.rev; }
    115 
    116     /**
    117      */
    118     void push_back(const Commitment&);
    119 
    120     /**
    121      */
    122     void reserve(size_t i);
     92    const Commitment& latest_commit(std::string author) const;
    12393
    12494    /**
     
    142112    */
    143113    struct log_receiver_baton {
    144       std::vector<std::string> authors;
    145       std::vector<std::string> commit_dates;
    146       std::vector<std::string> msg;
    147       std::vector<size_t> rev;
     114      std::vector<Commitment> commits;
    148115    } lb_;
    149116
  • branches/replacing_gnuplot/lib/Stats.cc

    r589 r646  
    5757    revision_=svn_info.rev();
    5858    last_changed_rev_=svn_info.last_changed_rev();
     59    reset();
    5960  }
    6061
     
    6869  {
    6970    if (vec.empty()){
    70       vec.resize(last_changed_rev(),0);
    71       return;
    72     }
    73     std::partial_sum(vec.begin(),vec.end(),vec.begin());
     71      // just to allow call to vec.back() below
     72      vec.resize(1,0);
     73    }
     74    else
     75      std::partial_sum(vec.begin(),vec.end(),vec.begin());
    7476    // static_cast to remove annoying compiler warning
    7577    if (vec.size() < static_cast<size_t>(revision()+1))
    76       vec.insert(vec.end(), revision()+1-vec.size(), vec.back());
     78      vec.resize(revision()+1, vec.back());
    7779  }
    7880
     
    100102    add_author(user);
    101103
    102     // FIXME: Peter, remove repeat
    103     std::vector<unsigned int>& code = code_stats()[user];
    104     if (code.size() < rev+1){
    105       code.reserve(rev+1);
    106       code.resize(rev);
    107       if (lt == LineTypeParser::code)
    108         code.push_back(n);
    109       else
    110         code.push_back(0);
     104    add(code_stats()[user], rev, lt==LineTypeParser::code, n);
     105    add(comment_stats()[user], rev, lt==LineTypeParser::comment, n);
     106    add(other_stats()[user], rev, lt==LineTypeParser::other, n);
     107    add(copyright_stats()[user], rev, lt==LineTypeParser::copyright, n);
     108  }
     109
     110
     111  void Stats::add(std::vector<unsigned int>& vec, unsigned int rev, bool x,
     112                  unsigned int n)
     113  {
     114    if (vec.size() < rev+1){
     115      vec.reserve(rev+1);
     116      vec.resize(rev);
     117      if (x) {
     118        assert(vec.size()+1<vec.max_size());
     119        vec.push_back(n);
     120      }
     121      else {
     122        assert(vec.size()+1<vec.max_size());
     123        vec.push_back(0);
     124      }
    111125    }
    112     else if (lt == LineTypeParser::code)
    113       code[rev]+=n;
    114 
    115     std::vector<unsigned int>& comments = comment_stats()[user];
    116     if (comments.size() < rev+1){
    117       comments.reserve(revision() + 1);
    118       comments.insert(comments.end(), rev - comments.size(), 0);
    119       if (lt == LineTypeParser::comment)
    120         comments.push_back(n);
    121       else
    122         comments.push_back(0);
    123     }
    124     else if (lt == LineTypeParser::comment)
    125       comments[rev]+=n;
    126 
    127     std::vector<unsigned int>& other = other_stats()[user];
    128     if (other.size() < rev+1){
    129       other.reserve(revision() + 1);
    130       other.insert(other.end(), rev - other.size(), 0);
    131       if (lt == LineTypeParser::other)
    132         other.push_back(n);
    133       else
    134         other.push_back(0);
    135     }
    136     else if (lt == LineTypeParser::other)
    137       other[rev]+=n;
    138 
    139     std::vector<unsigned int>& copy = copyright_stats()[user];
    140     if (copy.size() < rev+1){
    141       copy.reserve(revision() + 1);
    142       copy.insert(copy.end(), rev - copy.size(), 0);
    143       if (lt == LineTypeParser::copyright)
    144         copy.push_back(n);
    145       else
    146         copy.push_back(0);
    147     }
    148     else if (lt == LineTypeParser::copyright)
    149       copy[rev]+=n;
    150   }
     126    else if (x)
     127      vec[rev]+=n;
     128  }
    151129
    152130
     
    279257      std::string name;
    280258      std::getline(is, name);
    281       if (name.empty())
    282         continue;
    283259      std::vector<unsigned int>& vec=m[name];
    284       svn_revnum_t rev=0;
    285       while (rev < last_changed_rev() && is.good()) {
    286         unsigned int count;
    287         is >> count;
    288         if ( rev+1 > static_cast<svn_revnum_t>(vec.size()) )
     260      std::string line;
     261      std::getline(is, line);
     262      std::stringstream ss(line);
     263      while (ss.good()) {
     264        svn_revnum_t rev=0;
     265        unsigned int count=0;
     266        ss >> rev;
     267        ss >> count;
     268        if (!count)
     269          break;
     270        if (rev+1 < static_cast<svn_revnum_t>(vec.size()) )
    289271          vec.resize(rev+1);
    290         vec[rev] = count;
    291         is >> rev;
    292       }
     272        vec[rev]=count;
     273      }
     274      accumulate(vec);
    293275    }
    294276  }
     
    359341    calc_total();
    360342    calc_all();
     343    assert(total_stats().size());
     344    assert(code_stats().size());
     345    assert(comment_or_copy_stats().size());
     346    assert(other_stats().size());
    361347  }
    362348
     
    364350                          const std::string& linetype) const
    365351  {
     352    assert(total_stats().size());
    366353    plot_init(filename);
    367354    GnuplotFE* gp=GnuplotFE::instance();
     
    490477    os << cache_check_str() << "\n";
    491478    os << last_changed_rev() << " ";
    492     os << authors().size() << " ";
     479    os << authors().size() << "\n";
    493480
    494481    std::copy(authors().begin(), authors().end(),
     
    506493    for (A2VConstIter i(m.begin()); i!=m.end(); ++i){
    507494      os << i->first << "\n";
    508       os << i->second.front() << " ";
    509       for (size_t j=1; j<i->second.size(); ++j)
    510         if (i->second[j] != i->second[j-1])
     495      assert(i->second.size());
     496      if (i->second[0])
     497        os << 0 << " " << i->second[0] << " ";
     498      for (size_t j=1; j<i->second.size(); ++j) {
     499        // only print if stats changes in this rev
     500        if (i->second[j] != i->second[j-1]) {
    511501          os << j << " " << i->second[j] - i->second[j-1] << " ";
    512       os << last_changed_rev()+1 << " ";
     502        }
     503      }
     504      os << "\n";
    513505    }
    514506  }
     
    518510    for (size_t i=0; i<stats_.size(); ++i){
    519511      stats_[i].clear();
    520       std::vector<unsigned int> vec;
    521       stats_[i]["all"] = vec;
     512      stats_[i]["all"]=std::vector<unsigned int>(revision_+1);
    522513    }
    523514    authors_.clear();
     
    538529
    539530 
    540   size_t Stats::operator()(int linetype, std::string author, size_t rev) const
     531  size_t Stats::operator()(int linetype, std::string author,
     532                           svn_revnum_t rev) const
    541533  {
    542534    assert(linetype<=LineTypeParser::total);
     535    assert(static_cast<size_t>(linetype) < stats_.size());
     536    assert(rev>=0);
    543537    A2VConstIter i = stats_[linetype].find(author);
    544     if (i==stats_[linetype].end())
    545       throw std::runtime_error(author + " does not exist");
     538    if (i==stats_[linetype].end()){
     539      std::stringstream msg;
     540      msg << __FILE__ << ": author: " << author << " does not exist"; 
     541      throw std::runtime_error(msg.str());
     542    }
     543    assert(rev < static_cast<svn_revnum_t>(i->second.size()));
    546544    return i->second[rev];
    547545  }
  • branches/replacing_gnuplot/lib/Stats.h

    r589 r646  
    142142       \throw if \a author does not exist
    143143     */
    144     size_t operator()(int linetype, std::string author, size_t rev) const;
     144    size_t operator()(int linetype, std::string author, svn_revnum_t rev) const;
    145145
    146146  protected:
     
    200200  private:
    201201    void accumulate(std::vector<unsigned int>& vec) const;
     202    void add(std::vector<unsigned int>& vec, unsigned int rev, bool x,
     203             unsigned int n);
     204
    202205    virtual void do_parse(const std::string&)=0;
    203206   
  • branches/replacing_gnuplot/lib/first_page.cc

    r556 r646  
    5959    using namespace std;
    6060    set<string> authors;
    61     authors.insert(log.author().begin(), log.author().end());
     61    std::transform(log.commits().begin(), log.commits().end(),
     62                   std::inserter(authors, authors.begin()), GetAuthor());
    6263    // erase invalid authors
    6364    authors.erase("");
     
    8283                                 size_t nof_authors, std::string url)
    8384  {
    84     assert(log.date().size());
    85     Date begin(log.date()[0]);
    86     Date end(log.date().back());
     85    assert(log.commits().size());
     86    Date begin(log.commits()[0].date());
     87    Date end(log.commits().back().date());
    8788    std::string timefmt("%a, %e %b %Y  %H:%M:%S");
    8889
     
    101102    os << end.difftime(begin);
    102103    os << "</td></tr>\n"
    103        << "<tr><td>Smallest Revision:</td><td>" << log.revision()[0]
    104        << "</td></tr>\n"
    105        << "<tr><td>Largest Revision:</td><td>" << log.revision().back()
    106        << "</td></tr>\n"
    107        << "<tr><td>Revision Count:</td><td>" << log.revision().size()
     104       << "<tr><td>Smallest Revision:</td><td>" << log.commits()[0].revision()
     105       << "</td></tr>\n"
     106       << "<tr><td>Largest Revision:</td><td>" <<log.commits().back().revision()
     107       << "</td></tr>\n"
     108       << "<tr><td>Revision Count:</td><td>" << log.commits().size()
    108109       << "</td></tr>\n"
    109110       << "<tr><td>Number of Authors:</td><td>" << nof_authors
     
    154155
    155156    os << "</table></div>\n";
    156    
    157157  }
    158158
     
    166166       << "</th></tr></thead>\n";
    167167
    168     std::vector<std::string>::const_reverse_iterator a=log.author().rbegin();
    169     std::vector<std::string>::const_reverse_iterator d=log.date().rbegin();
    170     std::vector<std::string>::const_reverse_iterator m=log.message().rbegin();
    171     std::vector<size_t>::const_reverse_iterator r=log.revision().rbegin();
    172     assert(log.author().size()==log.date().size());
    173     assert(log.author().size()==log.message().size());
    174     assert(log.author().size()==log.revision().size());
    175168    os << "<tr><td>Author</td><td>Date</td><td>Rev</td><td>Added</td>"
    176169       << "<td>Removed</td><td>Message</td></tr>\n";
     
    179172    const size_t maxlength = 80;
    180173    const Configuration& conf = Configuration::instance();
    181     for (size_t i=0; i<10 && a!=log.author().rend(); ++i) {
     174    typedef std::vector<Commitment>::const_reverse_iterator iter;
     175    for (iter i=log.commits().rbegin();
     176         i < std::min(i+10,log.commits().rend()); ++i) {
    182177      os << "<tr><td>"
    183          << anchor(std::string("classic/")+*a+"/total/index.html",*a)
     178         << anchor(std::string("classic/")+i->author()+"/total/index.html",
     179                   i->author())
    184180         << "</td>";
    185       Date date(*d);
     181      Date date(i->date());
    186182      os << "<td>" << date(timefmt) << "</td>";
    187183      os << "<td>";
    188       os << trac_revision(*r);
     184      os << trac_revision(i->revision());
    189185      os << "</td>";
    190186      os << "<td>";
    191       int added = stats["add"](LineTypeParser::total, "all", *r) -
    192         stats["add"](LineTypeParser::total, "all", *r - 1);
     187      int added = stats["add"](LineTypeParser::total, "all", i->revision()) -
     188        stats["add"](LineTypeParser::total, "all", i->revision() - 1);
    193189      os << added;
    194190      os << "</td>";
    195191      os << "<td>";
    196       os << added - (stats["blame"](LineTypeParser::total, "all", *r) -
    197                      stats["blame"](LineTypeParser::total, "all", *r - 1));
     192      os << added-(stats["blame"](LineTypeParser::total, "all", i->revision()) -
     193                   stats["blame"](LineTypeParser::total,"all",i->revision()-1));
    198194      os << "</td>";
    199195      os << "<td>";
    200       std::string mess = *m;
     196      std::string mess = i->message();
    201197      // replace newlines with space
    202198      std::replace(mess.begin(), mess.end(), '\n', ' ');
     
    215211
    216212      os << "</td></tr>\n";
    217       ++a;
    218       ++d;
    219       ++m;
    220       ++r;
    221213    }
    222214    os << "</table></div>\n";
  • branches/replacing_gnuplot/lib/html_utility.cc

    r589 r646  
    2525#include "html_utility.h"
    2626
     27#include "config.h"
    2728#include "Configuration.h"
    2829#include "Date.h"
     
    6970                 PACKAGE_STRING, 0, "");
    7071    if (DEV_BUILD)
    71       os << " (r" << svn_revision() << ")";
     72      os << " (dev build r" << svn_revision() << ")";
    7273    os << "\n</p>\n</div>\n</body>\n</html>\n";
    7374  }
     
    181182
    182183
    183   std::string trac_revision(size_t r, std::string color)
     184  std::string trac_revision(svn_revnum_t r, std::string color)
    184185  {
    185186    const Configuration& conf = Configuration::instance();
  • branches/replacing_gnuplot/lib/html_utility.h

    r589 r646  
    3030#include <string>
    3131#include <vector>
     32
     33#include <subversion-1/svn_types.h>
    3234
    3335namespace theplu{
     
    7173  /// given otherwise just a string corresponding to passed parameter.
    7274  ///
    73   std::string trac_revision(size_t, std::string color="");
     75  std::string trac_revision(svn_revnum_t, std::string color="");
    7476
    7577}} // end of namespace svndigest end of namespace theplu
  • branches/replacing_gnuplot/lib/subversion_info.cc.in

    r581 r646  
    2828namespace svndigest{
    2929
     30  std::string compilation_date(void)
     31  {
     32    return __DATE__;
     33  }
     34
     35
     36  std::string compilation_time(void)
     37  {
     38    return __TIME__;
     39  }
     40
     41
    3042  std::string svn_revision(void)
    3143  {
  • branches/replacing_gnuplot/lib/subversion_info.h

    r569 r646  
    3030namespace svndigest{
    3131
     32  // These functions are (mis)placed here to reflect compilation time
     33  // of subversion_info.cc. Previously, __TIME__ macro was placed in
     34  // `bin/Parameter.cc' and since the Parameter is almost independent
     35  // of other parts of the package, that compilation time does not
     36  // very accurately reflect the building time of the svndigest
     37  // binary. subversion_info.cc is at least modified when updating
     38  // against repository and therefore these functions will return a
     39  // time no earlier than last `svn update'
     40  std::string compilation_date(void);
     41  std::string compilation_time(void);
     42
    3243  std::string svn_revision(void);
    3344
  • branches/replacing_gnuplot/lib/utility.cc

    r589 r646  
    2323
    2424#include "utility.h"
     25
     26#include "subversion_info.h"
     27#include "config.h"
    2528
    2629#include <cassert>
     
    321324
    322325
     326  std::string version_string(void)
     327  {
     328    std::stringstream ss;
     329    ss << " (";
     330    if (DEV_BUILD)
     331      ss << "r" << svn_revision() << " ";
     332    ss << "compiled " << compilation_time() << ", " << compilation_date()
     333       << ")";
     334    return ss.str();
     335  }
     336
     337
    323338  std::string match(std::string::const_iterator& first,
    324339                    const std::string::const_iterator& last,
  • branches/replacing_gnuplot/lib/utility.h

    r589 r646  
    200200  inline std::string trim(std::string str) { return htrim(ltrim(str)); }
    201201
     202  ///
     203  /// \return string with version info
     204  ///
     205  std::string version_string(void);
     206 
    202207
    203208  template <typename T>
  • branches/replacing_gnuplot/test/Makefile.am

    r607 r646  
    2323# 02111-1307, USA.
    2424
    25 check_PROGRAMS = config_test date gnuplot_pipe \
    26   parser trac utility_test
     25check_PROGRAMS = config_test date_test gnuplot_pipe_test \
     26  parser_test trac_test utility_test
    2727
    2828# these tests are only for developers since we do not distribute test repository
    2929if HAVE_SVN_WC
    30 check_PROGRAMS += copyright stats_test
     30check_PROGRAMS += copyright_test stats_test
    3131endif
    3232
     
    4545
    4646
    47 LDADD = $(STATICFLAG) @builddir@/libsvndigesttest.la \
    48   @top_builddir@/lib/libsvndigest.la
     47LDADD = @builddir@/libsvndigesttest.la \
     48  @top_builddir@/lib/libsvndigest.la \
     49  $(SVNDIGEST_LIBS)
     50AM_LDFLAGS = $(STATICFLAG) $(SVNDIGEST_LDFLAGS)
    4951
    50 AM_CPPFLAGS = -I@top_srcdir@/lib
     52AM_CPPFLAGS = -I@top_srcdir@/lib $(SVNDIGEST_CPPFLAGS)
     53AM_CXXFLAGS = $(SVNDIGEST_CXXFLAGS)
    5154
    5255libsvndigesttest_la_SOURCES = Suite.cc
    5356
    5457config_test_SOURCES = config_test.cc
    55 copyright_SOURCES = copyright.cc
    56 date_SOURCES = date.cc
    57 gnuplot_pipe_SOURCES = gnuplot_pipe.cc
    58 parser_SOURCES = parser.cc
     58copyright_test_SOURCES = copyright_test.cc
     59date_test_SOURCES = date_test.cc
     60gnuplot_pipe_test_SOURCES = gnuplot_pipe_test.cc
     61parser_test_SOURCES = parser_test.cc
    5962stats_test_SOURCES = stats_test.cc
    60 trac_SOURCES = trac.cc
     63trac_test_SOURCES = trac_test.cc
    6164utility_test_SOURCES = utility_test.cc
    6265
     
    6972# some tests need the test repo to be checked out
    7073stats_test_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
    71 copyright_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
     74copyright_test_DEPENDENCIES = $(toy_project) @top_builddir@/lib/libsvndigest.la
     75
     76@top_builddir@/lib/libsvndigest.la:
     77  @cd @top_builddir@/lib/ && $(MAKE) $(AM_MAKEFLAGS);
    7278
    7379$(toy_project):
     
    7682
    7783clean-local:
    78   rm -rf *.png *.tmp *~ check_repo_status.sh test_repo.sh \
    79   $(targetdir)
     84  rm -rf *.png *.tmp *~ $(targetdir)
     85
     86.PHONY: @top_builddir@/lib/libsvndigest.la
Note: See TracChangeset for help on using the changeset viewer.