Changeset 543


Ignore:
Timestamp:
Jan 4, 2008, 3:10:54 AM (13 years ago)
Author:
Peter Johansson
Message:

AddStats - number of added lines is counted - fixes ticket:82

Location:
trunk/lib
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/lib/AddStats.cc

    r541 r543  
    22
    33/*
    4   Copyright (C) 2005 Peter Johansson
    5   Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
     4  Copyright (C) 2008 Peter Johansson
    65
    76  This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    2322*/
    2423
    25 #include "BlameStats.h"
     24#include "AddStats.h"
    2625
    27 #include "Functor.h"
    28 #include "GnuplotFE.h"
    2926#include "SVNblame.h"
    30 #include "SVNinfo.h"
    3127#include "SVNlog.h"
    3228#include "utility.h"
     
    3531#include <cassert>
    3632#include <cstdlib>
    37 #include <fstream>
    38 #include <iostream>
    39 #include <iterator>
    4033#include <map>
    41 #include <numeric>
    4234#include <string>
    43 #include <sstream>
    44 #include <unistd.h>
    45 #include <utility>
    4635#include <vector>
    4736
     37//debug
     38#include <iostream>
    4839
    4940namespace theplu{
     
    5142
    5243
    53   BlameStats::BlameStats(const std::string& path)
     44  AddStats::AddStats(const std::string& path)
    5445    : Stats(path)
    5546  {
     
    5748
    5849
    59   BlameStats::BlameStats(const BlameStats& other)
     50  AddStats::AddStats(const AddStats& other)
    6051  : Stats(other)
    6152  {
     
    6354
    6455
    65   void BlameStats::fill_in(Author2Vector& a2v, svn_revnum_t rev)
    66   {
    67     assert(rev);
    68     for (std::set<std::string>::const_iterator iter(authors().begin());
    69          iter!=authors().end(); ++iter) {
    70       std::vector<u_int>& vec = a2v[*iter];
    71       vec.resize(revision()+1);
    72       assert(rev<static_cast<svn_revnum_t>(vec.size()));
    73       vec[rev]=vec[rev-1];
    74     }
    75   }
    76 
    77 
    78   void BlameStats::do_parse(const std::string& path)
     56  void AddStats::do_parse(const std::string& path)
    7957  {
    8058    Parser parser(path);
     
    8765      SVNblame svn_blame(path, *rev_iter);
    8866      while (svn_blame.valid()) {
    89         add(svn_blame.author(), *rev_iter, parser.parse(svn_blame.line()));
     67        std::cout << path << " " << *rev_iter << " " << svn_blame.revision() << " " << svn_blame.author() << "\n";
     68        if (*rev_iter==svn_blame.revision())
     69          add(svn_blame.author(), *rev_iter, parser.parse(svn_blame.line()));
    9070        // I dont trust blame and log behave consistent (stop-on-copy).
    9171        revs.insert(svn_blame.revision());
     
    9474    }
    9575   
    96     // filling in pristine revisions
    97     RevSet::iterator rev_iter=revs.begin();
    98     for (svn_revnum_t rev = 1; rev<=revision(); ++rev){
    99       if (rev==*rev_iter)
    100         ++rev_iter;
    101       else {
    102         fill_in(code_,rev);
    103         fill_in(comments_,rev);
    104         fill_in(other_,rev);
    105       }
    106     }
     76    accumulate_stats();
    10777  }
    10878
  • trunk/lib/AddStats.h

    r541 r543  
    1 #ifndef _theplu_svndigest_blame_stats_
    2 #define _theplu_svndigest_blame_stats_
     1#ifndef _theplu_svndigest_add_stats_
     2#define _theplu_svndigest_add_stats_
    33
    44// $Id$
    55
    66/*
    7   Copyright (C) 2005 Peter Johansson
    8   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
    9   Copyright (C) 2007 Peter Johansson
     7  Copyright (C) 2008 Peter Johansson
    108
    119  This file is part of svndigest, http://trac.thep.lu.se/svndigest
     
    3533  /// Class taking care of statistics from svn.
    3634  ///
    37   class BlameStats : public Stats
     35  class AddStats : public Stats
    3836  {
    3937  public:
     
    4139    /// @brief Default Constructor
    4240    ///
    43     explicit BlameStats(const std::string& path);
     41    explicit AddStats(const std::string& path);
    4442
    45     BlameStats(const BlameStats& other);
     43    AddStats(const AddStats& other);
    4644
    4745  private:
    4846    void do_parse(const std::string&);
    49     void fill_in(Author2Vector&, svn_revnum_t rev);
    5047
    5148  };
  • trunk/lib/Makefile.am

    r540 r543  
    2626noinst_LTLIBRARIES = libsvndigest.la
    2727
    28 noinst_HEADERS = Alias.h BlameStats.h ClassicStats.h ColumnStream.h \
     28noinst_HEADERS = AddStats.h Alias.h BlameStats.h ClassicStats.h ColumnStream.h \
    2929  Commitment.h Configuration.h css.h\
    3030  Date.h Directory.h File.h first_page.h Functor.h Gnuplot.h GnuplotFE.h \
     
    3333  SVNinfo.h SVNlog.h SVNproperty.h Trac.h utility.h
    3434
    35 libsvndigest_la_SOURCES = Alias.cc BlameStats.cc \
     35libsvndigest_la_SOURCES = AddStats.cc Alias.cc BlameStats.cc \
    3636  ClassicStats.cc ColumnStream.cc \
    3737  Commitment.cc Configuration.cc \
     
    4747
    4848clean-local:
    49   rm -rf *~ subversion_info.h
     49  rm -rf *~
    5050
    5151all-local:
     
    6666  revision=`$(SVNVERSION) $(top_srcdir)` ;\
    6767  year=`svn info $(top_srcdir)| sed -n  's/.*Date: \(.*\)-..-.*/\1/p'`;\
    68   echo $$year; \
    6968  $(SED) -e 's/sub_2_svn_revision/'$$revision'/g' \
    7069  -e 's/sub_2_svn_year/'$$year'/g'  subversion_info.h.in >> $@ ;
  • trunk/lib/StatsCollection.cc

    r538 r543  
    2424#include "StatsCollection.h"
    2525
     26#include "AddStats.h"
    2627#include "BlameStats.h"
    2728#include "ClassicStats.h"
     
    4445    stats_["classic"] = new ClassicStats(path);
    4546    stats_["blame"] = new BlameStats(path);
     47    stats_["add"] = new AddStats(path);
    4648  }
    4749
Note: See TracChangeset for help on using the changeset viewer.