Changeset 225 for trunk/lib/SVN.cc


Ignore:
Timestamp:
Mar 11, 2007, 12:41:51 PM (15 years ago)
Author:
Peter Johansson
Message:

copyright based on log is printed to cout refs #36

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SVN.cc

    r195 r225  
    33/*
    44  Copyright (C) 2006 Jari Häkkinen
     5  Copyright (C) 2007 Peter Johansson
    56
    67  This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest
     
    2728#include <string>
    2829#include <vector>
     30
     31#include <iostream>
    2932
    3033#include <apr_allocator.h>
     
    204207    struct log_receiver_baton lb;
    205208    lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored.
     209    lb.authors.reserve(head.value.number+1); // revision 0 is also stored.
     210    lb.rev.reserve(head.value.number+1); // revision 0 is also stored.
    206211    if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, true,
    207212                             log_message_receiver, static_cast<void*>(&lb),
     
    211216    svn_pool_destroy(subpool);
    212217    return lb.commit_dates;
     218  }
     219
     220
     221  std::vector<std::string> SVN::authors(const std::string& path)
     222  {
     223    // Allocate space in subpool to pool_ for apr_path (here a string).
     224    apr_pool_t *subpool = svn_pool_create(pool_);
     225    apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
     226    // Copy path to apr_path.
     227    (*((const char **) apr_array_push(apr_path))) =
     228      apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
     229
     230    // Setup to retrieve all commit logs.
     231    svn_opt_revision_t peg, start, head;
     232    peg.kind=svn_opt_revision_unspecified;
     233    start.kind=svn_opt_revision_number;
     234    start.value.number=0;
     235    head.kind=svn_opt_revision_head;
     236    svn_error_t* err=NULL;
     237    // Retrieving the last revision is only needed for the reserve
     238    // call below, not needed for the functionality here.
     239    if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
     240                                      subpool)))
     241      cleanup(err, subpool, "commit_dates: svn_ra_get_latest_revnum failed");
     242    // The struct we want to pass through to all log_message_receiver
     243    // calls, here we only want to push all commit dates into a
     244    // std::vector<std::string>.
     245    struct log_receiver_baton lb;
     246    lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored.
     247    lb.authors.reserve(head.value.number+1); // revision 0 is also stored.
     248    lb.rev.reserve(head.value.number+1); // revision 0 is also stored.
     249    if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, true,
     250                             log_message_receiver, static_cast<void*>(&lb),
     251                             context_, subpool)))
     252      // cleanupp will throw an exception
     253      cleanup(err, subpool, "commit_dates: svn_client_log3 failed");
     254    svn_pool_destroy(subpool);
     255    return lb.authors;
     256  }
     257
     258
     259  std::vector<size_t> SVN::revisions(const std::string& path)
     260  {
     261    // Allocate space in subpool to pool_ for apr_path (here a string).
     262    apr_pool_t *subpool = svn_pool_create(pool_);
     263    apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
     264    // Copy path to apr_path.
     265    (*((const char **) apr_array_push(apr_path))) =
     266      apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
     267
     268    // Setup to retrieve all commit logs.
     269    svn_opt_revision_t peg, start, head;
     270    peg.kind=svn_opt_revision_unspecified;
     271    start.kind=svn_opt_revision_number;
     272    start.value.number=0;
     273    head.kind=svn_opt_revision_head;
     274    svn_error_t* err=NULL;
     275    // Retrieving the last revision is only needed for the reserve
     276    // call below, not needed for the functionality here.
     277    if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
     278                                      subpool)))
     279      cleanup(err, subpool, "commit_dates: svn_ra_get_latest_revnum failed");
     280    // The struct we want to pass through to all log_message_receiver
     281    // calls, here we only want to push all commit dates into a
     282    // std::vector<std::string>.
     283    struct log_receiver_baton lb;
     284    lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored.
     285    lb.authors.reserve(head.value.number+1); // revision 0 is also stored.
     286    lb.rev.reserve(head.value.number+1); // revision 0 is also stored.
     287    if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, true,
     288                             log_message_receiver, static_cast<void*>(&lb),
     289                             context_, subpool)))
     290      // cleanupp will throw an exception
     291      cleanup(err, subpool, "commit_dates: svn_client_log3 failed");
     292    svn_pool_destroy(subpool);
     293    return lb.rev;
    213294  }
    214295
     
    244325    else
    245326      throw SVNException("No date defined for revision: " + rev);
     327    if (author && author[0])
     328      lb->authors.push_back(author);
     329    else
     330      lb->authors.push_back("");
     331    lb->rev.push_back(rev);
     332
    246333    return SVN_NO_ERROR;
    247334  }
Note: See TracChangeset for help on using the changeset viewer.