Changeset 256


Ignore:
Timestamp:
Apr 30, 2007, 1:17:36 PM (14 years ago)
Author:
Peter Johansson
Message:

reimplementing some part of print_main_page using Commitment class

Location:
trunk/lib
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Commitment.cc

    r255 r256  
    2323
    2424#include "Commitment.h"
     25#include "Date.h"
    2526
    2627#include <string>
     
    3031
    3132
    32   Commitment::Commitment(std::string author, std::string date,
     33  Commitment::Commitment(void)
     34  {
     35  }
     36
     37
     38  Commitment::Commitment(std::string author, const Date& date,
    3339                         std::string msg, size_t rev)
    3440    : author_(author), date_(date), msg_(msg), rev_(rev)
  • trunk/lib/Commitment.h

    r255 r256  
    2525*/
    2626
     27#include "Date.h"
     28
    2729#include <string>
    2830
     
    4042
    4143    /**
     44       \brief Default contructor.
     45    */
     46    Commitment(void);
     47
     48    /**
    4249       \brief The contructor.
    4350    */
    44     Commitment(std::string author, std::string date, std::string msg,
     51    Commitment(std::string author, const Date& date, std::string msg,
    4552               size_t rev);
    4653
     
    5360       \return Date
    5461    */
    55     inline std::string date(void) const { return date_; }
     62    inline const Date& date(void) const { return date_; }
    5663
    5764    /**
     
    7380
    7481    std::string author_;
    75     std::string date_;
     82    Date date_;
    7683    std::string msg_;
    7784    size_t rev_;
     
    7986  };
    8087
     88 
     89  struct GreaterRevision
     90  {
     91    inline bool operator()(const Commitment& lhs, const Commitment& rhs)
     92    { return lhs.revision()>rhs.revision(); }
     93  };
     94
    8195}} // end of namespace svndigest and namespace theplu
    8296
  • trunk/lib/SVNlog.cc

    r234 r256  
    2323
    2424#include "SVNlog.h"
     25
     26#include "Commitment.h"
    2527#include "SVN.h"
    2628
     
    4850  }
    4951
     52 
     53  Commitment SVNlog::latest_commit(std::string name) const
     54  {
     55    std::vector<std::string>::const_reverse_iterator iter =
     56      find(author().rbegin(), author().rend(), name);
     57    size_t dist(std::distance(iter, author().rend()));
     58    if (!dist) {
     59      Commitment c;
     60      return c;
     61    }
     62    return Commitment(author()[dist-1], Date(date()[dist-1]),
     63                      message()[dist-1], revision()[dist-1]);
     64                                             
     65  }
    5066
    5167}} // end of namespace svndigest and namespace theplu
  • trunk/lib/SVNlog.h

    r253 r256  
    2626
    2727#include "SVN.h"
     28
     29#include "Commitment.h"
    2830
    2931#include <string>
     
    7779
    7880    /**
     81       \return Latest commit \a author did. If no author is found an
     82       empty Commitment (default constructor) is returned.
     83    */
     84    Commitment latest_commit(std::string author) const;
     85
     86    /**
    7987       \return Revisions
    8088    */
  • trunk/lib/html_utility.cc

    r254 r256  
    2424#include "html_utility.h"
    2525
     26#include "Commitment.h"
    2627#include "Date.h"
    2728#include "HtmlStream.h"
     
    239240
    240241    using namespace std;
    241     map<string, Date> latest_commit_date;
    242     assert(log.author().size()==log.date().size());
    243     typedef vector<string>::const_iterator iter;
    244     iter d=log.date().begin();
    245     for (iter a=log.author().begin();
    246          a!=log.author().end(); ++a, ++d) {
    247       latest_commit_date[*a]=Date(*d);
    248     }
     242    set<string> authors;
     243    authors.insert(log.author().begin(), log.author().end());
    249244    // erase invalid authors
    250     latest_commit_date.erase("");
    251     latest_commit_date.erase("no author");
    252 
    253     // vector of authors & date sorted with respect to date
    254     typedef vector<pair<string, Date> > vector;
    255     vector author_date;
    256     author_date.reserve(latest_commit_date.size());
    257     back_insert_iterator<vector> i(author_date);
    258     copy(latest_commit_date.begin(), latest_commit_date.end(), i);
    259     sort(author_date.begin(), author_date.end(),
    260          pair_value_compare<string,Date>());
    261 
    262     print_general_information(os, log, author_date.size());
    263     print_authors(os, author_date, log, stats);
     245    authors.erase("");
     246    authors.erase("no author");
     247
     248    vector<Commitment> latest_commit;
     249    latest_commit.reserve(authors.size());
     250    for (set<string>::const_iterator i(authors.begin()); i!=authors.end(); ++i)
     251      latest_commit.push_back(log.latest_commit(*i));
     252
     253    print_general_information(os, log, authors.size());
     254    sort(latest_commit.begin(), latest_commit.end(), GreaterRevision());
     255    print_authors(os, latest_commit, stats);
    264256    print_recent_logs(os, log);
    265257    os << "<hr width=100% />";
     
    375367
    376368  void print_authors(std::ostream& os,
    377                      const std::vector<std::pair<std::string,Date> >& auth_date,
    378                      const SVNlog& log, const Stats& stats)
     369                     const std::vector<Commitment>& lc,
     370                     const Stats& stats)
    379371  {
    380372    os << "<div class=\"main\">"
     
    392384    std::string timefmt("%b %d %H:%M:%S %Y");
    393385    using namespace std;
    394     for (vector<pair<string,Date> >::const_reverse_iterator i=auth_date.rbegin();
    395          i!=auth_date.rend(); ++i) {
     386    for (vector<Commitment>::const_iterator i=lc.begin(); i!=lc.end(); ++i) {
    396387      os << "<tr><td>"
    397          << anchor(string(i->first+"/total/index.html"),i->first)
    398          << "</td><td>" << stats.lines(i->first) << " ("
    399          << 100*stats.lines(i->first)/stats.lines() << "%)</td>"
    400          << "<td>" << stats.code(i->first) << " ("
    401          << 100*stats.code(i->first)/stats.code() << "%)</td>"
    402          << "<td>" << stats.comments(i->first) << " ("
    403          << 100*stats.comments(i->first)/stats.comments() << "%)</td>"
    404          << "<td>" << i->second(timefmt) << "</td>"
     388         << anchor(string(i->author()+"/total/index.html"),i->author())
     389         << "</td><td>" << stats.lines(i->author()) << " ("
     390         << 100*stats.lines(i->author())/stats.lines() << "%)</td>"
     391         << "<td>" << stats.code(i->author()) << " ("
     392         << 100*stats.code(i->author())/stats.code() << "%)</td>"
     393         << "<td>" << stats.comments(i->author()) << " ("
     394         << 100*stats.comments(i->author())/stats.comments() << "%)</td>"
     395         << "<td>" << i->date()(timefmt) << "</td>"
    405396         <<"</tr>";
    406397    }
  • trunk/lib/html_utility.h

    r236 r256  
    3535namespace svndigest{
    3636
     37  class Commitment;
    3738  class Date;
    3839  class Stats;
     
    5758
    5859  void print_authors(std::ostream& os,
    59                      const std::vector<std::pair<std::string, Date> >&,
    60                      const SVNlog&, const Stats& stats);
     60                     const std::vector<Commitment>& latest_commit,
     61                     const Stats& stats);
    6162
    6263  ///
     
    7071  void print_main_page(const std::string&, const SVNlog&, const Stats&);
    7172   
    72   void print_recent_logs(std::ostream&, const SVNlog&);
     73  void print_recent_logs(std::ostream&, const SVNlog& log);
    7374   
    7475  ///
Note: See TracChangeset for help on using the changeset viewer.