Changeset 381


Ignore:
Timestamp:
Jun 21, 2007, 10:43:17 PM (13 years ago)
Author:
Jari Häkkinen
Message:

SVNblame redesigned.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/File.cc

    r380 r381  
    9696    HtmlStream hs(os);
    9797    SVNblame blame(path_);
    98     while (const struct SVNblame::blame_information* bi=blame.next()) {
    99       os << "<tr>\n<td class=\"number\">" << bi->revision
    100          << "</td>\n<td class=\"date\">"  << Date(bi->date)("%e %b %y")
     98    while (blame.valid()) {
     99      os << "<tr>\n<td class=\"number\">" << blame.revision()
     100         << "</td>\n<td class=\"date\">"  << Date(blame.date())("%e %b %y")
    101101         << "</td>\n<td class=\"author\">";
    102       hs << bi->author;
    103       os << "</td>\n<td class=\"number\">" << bi->line_no+1
     102      hs << blame.author();
     103      os << "</td>\n<td class=\"number\">" << blame.line_no()+1
    104104         << "</td>\n<td class=\"code\">";
    105       hs << bi->line;
     105      hs << blame.line();
    106106      os << "</td>\n</tr>\n";
     107      blame.next_line();
    107108    }
    108109    os << "</tbody>\n";
  • trunk/lib/SVNblame.cc

    r149 r381  
    22
    33/*
    4   Copyright (C) 2006 Jari Häkkinen
     4  Copyright (C) 2006, 2007 Jari Häkkinen
    55
    66  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    5757
    5858
    59   const SVNblame::blame_information* SVNblame::next(void)
     59  std::string SVNblame::author(void)
    6060  {
    61     blame_information *bi=NULL;
    62     if (blame_info_iterator_!=blame_receiver_baton_.blame_info.end()) {
    63       bi=*blame_info_iterator_;
    64       ++blame_info_iterator_;
    65     }
    66     return bi;
     61    return (*blame_info_iterator_)->author;
     62  }
     63
     64
     65  bool SVNblame::binary(void)
     66  {
     67    return binary_;
    6768  }
    6869
     
    8485
    8586
     87  std::string SVNblame::date(void)
     88  {
     89    return (*blame_info_iterator_)->date;
     90  }
     91
     92
     93  std::string SVNblame::line(void)
     94  {
     95    return (*blame_info_iterator_)->line;
     96  }
     97
     98
     99  apr_int64_t SVNblame::line_no(void)
     100  {
     101    return (*blame_info_iterator_)->line_no;
     102  }
     103
     104
     105  bool SVNblame::next_line(void)
     106  {
     107    if (valid())
     108      ++blame_info_iterator_;
     109    return valid();
     110  }
     111
     112
     113  svn_revnum_t SVNblame::revision(void)
     114  {
     115    return (*blame_info_iterator_)->revision;
     116  }
     117
     118
     119  bool SVNblame::valid(void)
     120  {
     121    return (blame_info_iterator_!=blame_receiver_baton_.blame_info.end());
     122  }
     123
    86124}} // end of namespace svndigest and namespace theplu
  • trunk/lib/SVNblame.h

    r380 r381  
    3535  class SVN;
    3636
    37   ///
    38   /// The SVNblame class is a utility class for taking care of 'svn
    39   /// blame' information. An 'svn blame' is performed on an item, the
    40   /// blame information for each line is traversed with
    41   /// SVNblame.next() calls giving access to the blame information in
    42   /// a blame_information struct.
    43   ///
     37  /**
     38    The SVNblame class is a utility class for taking care of 'svn
     39    blame' information. An 'svn blame' is performed on an item, the
     40    blame information for each line is traversed with
     41     SVNblame.next_line() and SVNblame.valid() calls giving access to
     42     the blame information.
     43  */
    4444  class SVNblame {
    4545  public:
    4646
    47     ///
    48     /// @brief Information return by subversion (blame) API
    49     ///
    50     /// @see Subversion API for blame usage.
    51     ///
     47    /**
     48       @brief The contructor.
     49
     50       The constructor performs an 'svn blame' on \a path and
     51       initializes the SVNblame object for statistics traversal using
     52       SVNblame::next_line() and SVNblame::valid().
     53    */
     54    explicit SVNblame(const std::string& path);
     55
     56    /**
     57       @brief The destructor.
     58    */
     59    ~SVNblame(void);
     60
     61    /**
     62       @brief Retrieve the blame date for the current line.
     63
     64       If current line is outside blame entries the behaviour is
     65       undefined.
     66
     67       @return The date.
     68    */
     69    std::string author(void);
     70
     71    /**
     72       Returns true if item is binary false otherwise
     73
     74       Binary files are invalid for 'svn blame'.
     75    */
     76    bool binary(void);
     77
     78    /**
     79       @brief Retrieve the blame date for the current line.
     80
     81       If current line is outside blame entries the behaviour is
     82       undefined.
     83
     84       @return The date.
     85    */
     86    std::string date(void);
     87
     88    /**
     89       @brief Retrieve the content of the current line.
     90
     91       If current line is outside blame entries the behaviour is
     92       undefined.
     93
     94       @return The line content.
     95    */
     96    std::string line(void);
     97
     98    /**
     99       @brief Retrieve the line number of the current line.
     100
     101       If current line is outside blame entries the behaviour is
     102       undefined.
     103
     104       @return The line number.
     105    */
     106    apr_int64_t line_no(void);
     107
     108    /**
     109       @brief Skip to the next line.
     110
     111       @return False if no more blame information is available, true
     112       otherwise.
     113    */
     114    bool next_line(void);
     115
     116    /**
     117       @brief Retrieve the blame revision of the current line.
     118
     119       If current line is outside blame entries the behaviour is
     120       undefined.
     121
     122       @return The blame revision.
     123    */
     124    svn_revnum_t revision(void);
     125
     126    /**
     127       @brief Check if more blame information is available.
     128
     129       @return True if valid information exists, false otherwise.
     130    */
     131    bool valid(void);
     132
     133  private:
     134
     135    /**
     136       @brief Copy Constructor, not implemented.
     137    */
     138    SVNblame(const SVNblame&);
     139
     140    /**
     141       @brief Information return by subversion (blame) API
     142
     143       @see Subversion API for blame usage.
     144    */
    52145    struct blame_information {
    53146      apr_int64_t line_no;
     
    57150      std::string line;
    58151    };
    59 
    60     ///
    61     /// @brief The contructor.
    62     ///
    63     /// The constructor performs an 'svn blame' on \a path and
    64     /// initializes the SVNblame object for statistics traversal using
    65     /// SVNblame::next().
    66     ///
    67     explicit SVNblame(const std::string& path);
    68 
    69     ///
    70     /// @brief The destructor.
    71     ///
    72     ~SVNblame(void);
    73 
    74     ///
    75     /// @brief Returns true if item is binary false otherwise
    76     ///
    77     /// Binary files are invalid for 'svn blame'.
    78     ///
    79     inline bool binary(void) { return binary_; }
    80 
    81     /**
    82        Traverse all lines in the item for statistics analysis. There
    83        is currently no way to reset the pointer to the beginning of
    84        item. The pointer is only valid while the SVNblame object is in
    85        scope.
    86 
    87        @return Pointer to a blame_information struct if more lines are
    88        available NULL otherwise.
    89 
    90        @see struct blame_information.
    91     */
    92     const blame_information* next(void);
    93 
    94   private:
    95 
    96     ///
    97     /// @brief Copy Constructor, not implemented.
    98     ///
    99     SVNblame(const SVNblame&);
    100152
    101153    // binary_ is true if item in any revision has been binary.
  • trunk/lib/Stats.cc

    r371 r381  
    33/*
    44  Copyright (C) 2005 Peter Johansson
    5   Copyright (C) 2006 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson
    66
    77  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    148148
    149149    SVNblame svn_blame(path);
    150     while (const SVNblame::blame_information * bi=svn_blame.next()) {
    151       assert(bi);
    152       add(bi->author, bi->revision, *count);
     150    while (svn_blame.valid()) {
     151      add(svn_blame.author(), svn_blame.revision(), *count);
     152      svn_blame.next_line();
    153153      ++count;
    154154    }
Note: See TracChangeset for help on using the changeset viewer.