Changeset 1255 for trunk


Ignore:
Timestamp:
Nov 1, 2010, 4:31:50 AM (10 years ago)
Author:
Peter Johansson
Message:

closes #214. Using tree.log to detect the first revision for the tree
and use that to set the x-range in plots. The call to tree.log is for
free since it will be re-cycled in printing the first page and we get
rid of the call to log of the repo log.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r1254 r1255  
    202202
    203203
    204 void set_dates(const std::string& repo, bool verbose)
    205 {
    206   if (verbose)
    207     std::cout << "Retrieving dates" << std::endl;
    208   SVNlog log(repo);
    209   std::vector<time_t> dates;
    210   dates.reserve(log.commits().size());
     204void set_dates(const svndigest::SVNlog& log)
     205{
     206  assert(!log.commits().empty());
     207  // all plots uses the same xmin
     208  Graph::rev_min(log.commits().begin()->revision());
     209
     210  /*
     211     Fill in dates for revisions in log. Revisions not seen in log
     212     should not be used and left equal to 0.
     213   */
     214  std::vector<time_t> dates(log.latest_commit().revision()+1, 0);
    211215  for (SVNlog::container::const_iterator iter=log.commits().begin();
    212216       iter!=log.commits().end(); ++iter) {
    213     assert(static_cast<svn_revnum_t>(dates.size())==iter->revision());
    214     dates.push_back(Date(iter->date()).seconds());
    215   }
     217    assert(iter->revision()<static_cast<svn_revnum_t>(dates.size()));
     218    dates[iter->revision()] = Date(iter->date()).seconds();
     219  }
     220
    216221  // all plots uses the same dates
    217222  Graph::set_dates(dates);
     
    229234  }
    230235 
    231   if (!option.revisions())
    232     set_dates(repo, option.verbose());
     236  if (!option.revisions()) {
     237    if (option.verbose())
     238      std::cout << "Retrieving dates" << std::endl;
     239    set_dates(tree.log());
     240  }
    233241
    234242  chdir(option.targetdir());
  • trunk/lib/Graph.cc

    r1202 r1255  
    2626
    2727#include <algorithm>
     28#include <cassert>
    2829#include <cmath>
    2930#include <sstream>
     
    3233namespace svndigest {
    3334
     35  svn_revnum_t Graph::rev_min_=0;
    3436  std::vector<time_t> Graph::xticks_;
    3537
     
    9092#ifdef HAVE_PLPLOT
    9193    if (!plots_) {
    92       // date[0] is not the oldest when repo is imported with cvs2svn
    93       xmin_= date_xticks() ? std::min(xticks_[0], xticks_[1]) : 0;
     94      assert(!date_xticks() || rev_min_<xticks_.size());
     95      assert(!date_xticks() || xticks_[rev_min_]);
     96      xmin_= date_xticks() ? xticks_[rev_min_] : 0;
    9497      xmax_= date_xticks() ? xticks_.back() : y.size();
    9598      xrange_=xmax_-xmin_;
     
    117120
    118121    SumVector::const_iterator iter = y.begin();
    119     svn_revnum_t x0=0;
     122    svn_revnum_t x0=rev_min_;
    120123    PLFLT y0=0;
    121124    for (; iter!=y.end(); ++iter) {
     
    162165
    163166
     167  void Graph::rev_min(svn_revnum_t rev)
     168  {
     169    rev_min_ = rev;
     170  }
     171
     172
    164173  void Graph::set_dates(const std::vector<time_t>& date)
    165174  {
     
    174183    PLFLT x1 = rev1;
    175184    if (date_xticks()) {
     185      assert(rev0<xticks_.size());
     186      assert(xticks_[rev0]);
    176187      x0 = xticks_[rev0];
     188      assert(rev1<xticks_.size());
     189      assert(xticks_[rev1]);
    177190      x1 = xticks_[rev1];
    178191    }
  • trunk/lib/Graph.h

    r1198 r1255  
    2727
    2828#include "Vector.h"
     29
     30#include <subversion-1/svn_types.h>
    2931
    3032#include <ctime>
     
    98100
    99101    /**
     102       Sets the left end of xrange to correspond to revision \a rev.
     103     */
     104    static void rev_min(svn_revnum_t rev);
     105
     106    /**
    100107       \brief Function setting the dates.
    101108
     
    144151    unsigned int plots_; // keep track of number of plots drawn
    145152    plstream pls_;
     153    static svn_revnum_t rev_min_;
    146154    std::string timeformat_;
    147155    std::string title_;
  • trunk/lib/Stats.cc

    r1231 r1255  
    442442    // FIXME: try keep a const& to avoid copying
    443443    SumVector total=get_vector(*stat, "all");   
    444     total.resize(revision());
     444    total.resize(revision()+1);
    445445    double yrange_max=1.03 * max_element(total) +1.0;
    446446    gp.ymax(yrange_max);
     
    454454      // FIXME: avoid this copying?
    455455      SumVector vec = get_vector(*stat,*i);
    456       vec.resize(revision());
     456      vec.resize(revision()+1);
    457457      if (max_element(vec)) {
    458458        author_cont.push_back(std::make_pair(*i,vec));
Note: See TracChangeset for help on using the changeset viewer.