Changeset 452


Ignore:
Timestamp:
Aug 17, 2007, 9:03:32 PM (16 years ago)
Author:
Peter Johansson
Message:

fixes #248 and refs #185

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/svndigest.cc

    r439 r452  
    164164                                   +tree->name()+"'");
    165165    print_css("svndigest.css");
    166     SVNlog local_log(option->root());
    167     print_main_page(tree->name(), local_log, stats,
    168                     tree->url());
     166    print_main_page(tree->name(), tree->log(), stats, tree->url());
    169167    mkdir("all");
    170168    mkdir("images");
  • trunk/lib/Commitment.cc

    r439 r452  
    2323
    2424#include "Commitment.h"
    25 #include "Date.h"
    2625
    2726#include <string>
     
    3635
    3736
    38   Commitment::Commitment(std::string author, const Date& date,
     37  Commitment::Commitment(std::string author, std::string date,
    3938                         std::string msg, size_t rev)
    4039    : author_(author), date_(date), msg_(msg), rev_(rev)
  • trunk/lib/Commitment.h

    r439 r452  
    2525*/
    2626
    27 #include "Date.h"
    28 
    2927#include <string>
    3028
     
    4947       \brief The contructor.
    5048    */
    51     Commitment(std::string author, const Date& date, std::string msg,
     49    Commitment(std::string author, std::string date, std::string msg,
    5250               size_t rev);
    5351
     
    6058       \return Date
    6159    */
    62     inline const Date& date(void) const { return date_; }
     60    inline std::string date(void) const { return date_; }
    6361
    6462    /**
     
    8078
    8179    std::string author_;
    82     Date date_;
     80    std::string date_;
    8381    std::string msg_;
    8482    size_t rev_;
  • trunk/lib/Directory.cc

    r447 r452  
    110110
    111111
    112   SVNlog Directory::log(void) const
    113   {
    114     // not yet implemented
    115     assert(0);
     112  SVNlog Directory::log_core(void) const
     113  {
     114    SVNlog log(path());
     115    for (NodeConstIterator i(daughters_.begin()); i != daughters_.end(); ++i)
     116      log += (*i)->log();
     117    return log;
    116118  }
    117119
  • trunk/lib/Directory.h

    r447 r452  
    7272
    7373    /**
    74        @return union of logs from daughter nodes.
    75     */
    76     SVNlog log(void) const;
    77 
    78     /**
    7974       @return The explicit string "directory", nothing else.
    8075    */
     
    9186
    9287  private:
     88    /**
     89       @return union of logs from daughter nodes.
     90    */
     91    SVNlog log_core(void) const;
     92
    9393    ///
    9494    /// @brief Copy Constructor, not implemented
  • trunk/lib/File.cc

    r447 r452  
    170170
    171171
    172   SVNlog File::log(void) const
     172  SVNlog File::log_core(void) const
    173173  {
    174174    return SVNlog(path());
  • trunk/lib/File.h

    r447 r452  
    5050
    5151    /**
    52        @return log of this File.
    53     */
    54     SVNlog log(void) const;
    55 
    56     /**
    5752       @return The explicit string "file", nothing else.
    5853    */
     
    7469
    7570  private:
     71    /**
     72       @return log of this File.
     73    */
     74    SVNlog log_core(void) const;
     75
    7676    ///
    7777    /// @brief Copy Constructor, not implemented
  • trunk/lib/LogIterator.cc

    r450 r452  
    2828#include <cassert>
    2929
     30#include <iostream>
    3031namespace theplu{
    3132namespace svndigest{
    3233
    3334  LogIterator::LogIterator(const SVNlog& log, size_t index)
    34     : log_(log), index_(index)
    35   {}
     35    : commit_(NULL), log_(log), index_(index)
     36  {
     37    update_commit();
     38  }
     39
     40 
     41  LogIterator::LogIterator(const LogIterator& other)
     42    : commit_(NULL), log_(other.log_), index_(other.index_)
     43  {
     44    update_commit();
     45  }
    3646
    3747 
     
    4353
    4454
     55  void LogIterator::update_commit(void)
     56  {
     57    if (commit_)
     58      delete commit_;
     59    if (index_<log_.author().size())
     60      commit_ = new Commitment(log_.author()[index_],
     61                               log_.date()[index_],
     62                               log_.message()[index_],
     63                               log_.revision()[index_]);
     64    else
     65      commit_ = NULL;
     66  }
     67
     68 
    4569  bool LogIterator::operator<(const LogIterator& other) const
    4670  {
     71    assert(&log_==&other.log_);
    4772    return index_<other.index_;
    4873  }
    4974
    5075
    51   const Commitment& LogIterator::operator*()
     76  const Commitment& LogIterator::operator*() const
    5277  {
    5378    assert(index_<log_.revision().size());
    54     if (!commit_)
    55       commit_ = new Commitment(log_.author()[index_],
    56                               log_.date()[index_],
    57                               log_.message()[index_],
    58                               log_.revision()[index_]);
     79    if (!commit_){
     80      std::cout << index_ << std::endl;
     81     
     82    }
     83    assert(commit_);
    5984    return *commit_;
    6085  }
    6186
    6287
    63   const Commitment* LogIterator::operator->(void)
     88  const Commitment* LogIterator::operator->(void) const
    6489  {
    6590    return &this->operator*();
     
    6994  LogIterator& LogIterator::operator++(void)
    7095  {
    71     if (index_<log_.revision().size()){
    72       ++index_;
    73       delete commit_;
    74       commit_ = NULL;
    75     }                               
     96    ++index_;
     97    if (index_>log_.revision().size())
     98      index_=log_.revision().size();
     99    update_commit();
    76100   
    77101    return *this;
  • trunk/lib/LogIterator.h

    r448 r452  
    4141    LogIterator(const SVNlog&, size_t index=0);
    4242   
     43    /**
     44       Copy Constructor
     45    */
     46    LogIterator(const LogIterator&);
     47
    4348    virtual ~LogIterator();
    4449
    4550    bool operator<(const LogIterator&) const;
    46     const Commitment* operator->();
    47     const Commitment& operator*();
     51    const Commitment* operator->() const;
     52    const Commitment& operator*() const;
    4853    LogIterator& operator++();
    4954
    5055  private:
    51     // Copy Constructor not implemented
    52     LogIterator(const LogIterator&);
    5356    // Assignment operator not implemented
    5457    LogIterator& operator=(const LogIterator&);
     58
     59    void update_commit(void);
    5560
    5661    Commitment* commit_;
  • trunk/lib/Node.cc

    r439 r452  
    2323
    2424#include "Node.h"
     25
     26#include "Date.h"
    2527#include "html_utility.h"
    2628#include "SVNlog.h"
     
    6062    lstat(path.c_str(),&nodestat);   // C api from sys/stat.h
    6163    link_ = S_ISLNK(nodestat.st_mode);
     64  }
     65
     66
     67  std::string Node::author(void) const
     68  {
     69    if (ignore())
     70      return svninfo_.last_changed_author();
     71    assert(log().author().size());
     72    return log().author().back();
    6273  }
    6374
     
    112123
    113124    }
    114     os << "<td>" << trac_revision(stats_.last_changed_rev()) << "</td>\n"
     125
     126    os << "<td>" << trac_revision(last_changed_rev()) << "</td>\n"
    115127       << "<td>" << author() << "</td>\n"
    116128       << "</tr>\n";
     129  }
     130
     131
     132  svn_revnum_t Node::last_changed_rev(void) const
     133  {
     134    if (ignore())
     135      return svninfo_.last_changed_rev();
     136    assert(log().revision().size());
     137    return log().revision().back();
     138  }
     139
     140
     141  SVNlog Node::log(void) const
     142  {
     143    if (ignore())
     144      return SVNlog();
     145    return log_core();
    117146  }
    118147
     
    216245        Commitment lc(log.latest_commit(*i));
    217246        os << "</td>" << "<td>" << trac_revision(lc.revision())
    218            << "</td>" << "<td>" << lc.date()(timefmt);
     247           << "</td>" << "<td>" << Date(lc.date())(timefmt);
    219248      }
    220249      else {
     
    244273    Commitment lc(log.latest_commit());
    245274    os << "<td>" << trac_revision(lc.revision()) << "</td>\n";
    246     os << "<td>" << lc.date()(timefmt)<< "</td>\n";
     275    os << "<td>" << Date(lc.date())(timefmt)<< "</td>\n";
    247276    os << "</tr>\n";
    248277    os << "</tbody>\n";
  • trunk/lib/Node.h

    r447 r452  
    6868    /// @brief Get the author of the latest commit.
    6969    ///
    70     inline const std::string& author(void) const
    71     { return svninfo_.last_changed_author(); }
     70    std::string author(void) const;
     71
    7272
    7373    /**
     
    110110    /// @brief Get the revision number of the latest commit.
    111111    ///
    112     inline svn_revnum_t last_changed_rev(void) const
    113     { return svninfo_.last_changed_rev(); }
     112    svn_revnum_t last_changed_rev(void) const;
    114113
    115114    /**
    116115       @return log of this node in a recursive manner.
    117116    */
    118     virtual SVNlog log(void) const=0;
     117    SVNlog log(void) const;
    119118
    120119    /**
     
    186185   
    187186  protected:
     187
     188    virtual SVNlog log_core(void) const=0;
    188189
    189190    ///
  • trunk/lib/SVNlog.cc

    r448 r452  
    2525
    2626#include "Commitment.h"
     27#include "LogIterator.h"
    2728#include "SVN.h"
    2829
     30#include <algorithm>
    2931#include <cassert>
    3032#include <string>
     
    3739  SVNlog::SVNlog(void)
    3840  {
    39     assert(date().size()==author().size());
    40     assert(date().size()==revision().size());
    41     assert(date().size()==message().size());
     41    assert(date().empty());
     42    assert(author().empty());
     43    assert(revision().empty());
     44    assert(message().empty());
    4245  }
    4346
     
    5861
    5962 
     63  LogIterator SVNlog::begin() const
     64  {
     65    return LogIterator(*this, 0);
     66  }
     67
     68
     69  LogIterator SVNlog::end() const
     70  {
     71    return LogIterator(*this, revision().size());
     72  }
     73
     74
    6075  bool SVNlog::exist(std::string name) const
    6176  {
     
    6883  Commitment SVNlog::latest_commit(void) const
    6984  {
    70     return Commitment(author().back(), Date(date().back()),
     85    return Commitment(author().back(), date().back(),
    7186                      message().back(), revision().back());
    7287                                             
     
    8499      return c;
    85100    }
    86     return Commitment(author()[dist-1], Date(date()[dist-1]),
     101    return Commitment(author()[dist-1], date()[dist-1],
    87102                      message()[dist-1], revision()[dist-1]);
    88103                                             
     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);
    89122  }
    90123
     
    114147
    115148
     149  void SVNlog::swap(SVNlog& rhs)
     150  {
     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);
     155  }
     156
     157
     158  SVNlog& operator+=(SVNlog& lhs, const SVNlog& rhs)
     159  {
     160    SVNlog log;
     161    LogIterator lhs_iter(lhs.begin());
     162    LogIterator rhs_iter(rhs.begin());
     163    while(lhs_iter<lhs.end() && rhs_iter<rhs.end()) {
     164      if (lhs_iter->revision() < rhs_iter->revision()) {
     165       
     166        log.push_back(*lhs_iter);
     167        ++lhs_iter;
     168      }
     169      else if (rhs_iter->revision()<lhs_iter->revision()) {
     170        log.push_back(*rhs_iter);
     171        ++rhs_iter;
     172      }
     173      else {
     174        log.push_back(*lhs_iter);
     175        ++lhs_iter;
     176        ++rhs_iter;
     177      }
     178    }
     179    while(lhs_iter<lhs.end()) {
     180        log.push_back(*lhs_iter);
     181        ++lhs_iter;
     182    }
     183    while(rhs_iter<rhs.end()) {
     184        log.push_back(*rhs_iter);
     185        ++rhs_iter;
     186    }
     187    lhs.swap(log);
     188    return lhs;
     189  }
     190
    116191}} // end of namespace svndigest and namespace theplu
  • trunk/lib/SVNlog.h

    r448 r452  
    2828
    2929#include "Commitment.h"
     30#include "LogIterator.h"
    3031
    3132#include <string>
     
    7273
    7374    /**
     75     */
     76    LogIterator begin(void) const;
     77
     78    /**
    7479       \return Dates
    7580    */
    7681    inline const std::vector<std::string>& date(void) const
    7782    { return lb_.commit_dates; }
     83
     84    /**
     85     */
     86    LogIterator end(void) const;
    7887
    7988    /**
     
    105114    { return lb_.rev; }
    106115
     116    /**
     117     */
     118    void push_back(const Commitment&);
     119
     120    /**
     121     */
     122    void reserve(size_t i);
     123
     124    /**
     125     */
     126    void swap(SVNlog&);
     127   
    107128  private:
    108129
     
    148169  /**
    149170   */
    150   //SVNlog& operator+=(SVNlog&, const SVNlog&);
     171  SVNlog& operator+=(SVNlog&, const SVNlog&);
    151172
    152173}} // end of namespace svndigest and namespace theplu
  • trunk/lib/first_page.cc

    r439 r452  
    7777    print_footer(os);
    7878    os.close();
    79 
    8079  }
    8180
     
    8382                                 size_t nof_authors, std::string url)
    8483  {
     84    assert(log.date().size());
    8585    Date begin(log.date()[0]);
    8686    Date end(log.date().back());
     
    144144         << "<td>" << stats.comments(i->author()) << " ("
    145145         << 100*stats.comments(i->author())/stats.comments() << "%)</td>"
    146          << "<td>" << i->date()(timefmt) << "</td>"
     146         << "<td>" << Date(i->date())(timefmt) << "</td>"
    147147         <<"</tr>";
    148148    }
Note: See TracChangeset for help on using the changeset viewer.