Changeset 234 for trunk/lib/SVN.cc


Ignore:
Timestamp:
Apr 9, 2007, 2:08:26 PM (14 years ago)
Author:
Peter Johansson
Message:

fixes #87 and #95 and #103 and #104 and #80 and #108, and refs #69

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SVN.cc

    r233 r234  
    178178    }
    179179    svn_pool_destroy(subpool);
    180   }
    181 
    182 
    183   std::vector<std::string> SVN::commit_dates(const std::string& path)
    184   {
    185     // Allocate space in subpool to pool_ for apr_path (here a string).
    186     apr_pool_t *subpool = svn_pool_create(pool_);
    187     apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
    188     // Copy path to apr_path.
    189     (*((const char **) apr_array_push(apr_path))) =
    190       apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
    191 
    192     // Setup to retrieve all commit logs.
    193     svn_opt_revision_t peg, start, head;
    194     peg.kind=svn_opt_revision_unspecified;
    195     start.kind=svn_opt_revision_number;
    196     start.value.number=0;
    197     head.kind=svn_opt_revision_head;
    198     svn_error_t* err=NULL;
    199     // Retrieving the last revision is only needed for the reserve
    200     // call below, not needed for the functionality here.
    201     if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
    202                                       subpool)))
    203       cleanup(err, subpool, "commit_dates: svn_ra_get_latest_revnum failed");
    204     // The struct we want to pass through to all log_message_receiver
    205     // calls, here we only want to push all commit dates into a
    206     // std::vector<std::string>.
    207     struct log_receiver_baton lb;
    208     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.
    211     if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, false,
    212                              log_message_receiver, static_cast<void*>(&lb),
    213                              context_, subpool)))
    214       // cleanupp will throw an exception
    215       cleanup(err, subpool, "commit_dates: svn_client_log3 failed");
    216     svn_pool_destroy(subpool);
    217     return lb.commit_dates;
    218180  }
    219181
     
    255217
    256218
    257   std::vector<std::string> SVN::authors(const std::string& path)
    258   {
    259     // Allocate space in subpool to pool_ for apr_path (here a string).
    260     apr_pool_t *subpool = svn_pool_create(pool_);
    261     apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
    262     // Copy path to apr_path.
    263     (*((const char **) apr_array_push(apr_path))) =
    264       apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
    265 
    266     // Setup to retrieve all commit logs.
    267     svn_opt_revision_t peg, start, head;
    268     peg.kind=svn_opt_revision_unspecified;
    269     start.kind=svn_opt_revision_number;
    270     start.value.number=0;
    271     head.kind=svn_opt_revision_head;
    272     svn_error_t* err=NULL;
    273     // Retrieving the last revision is only needed for the reserve
    274     // call below, not needed for the functionality here.
    275     if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
    276                                       subpool)))
    277       cleanup(err, subpool, "commit_dates: svn_ra_get_latest_revnum failed");
    278     // The struct we want to pass through to all log_message_receiver
    279     // calls, here we only want to push all commit dates into a
    280     // std::vector<std::string>.
    281     struct log_receiver_baton lb;
    282     lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored.
    283     lb.authors.reserve(head.value.number+1); // revision 0 is also stored.
    284     lb.rev.reserve(head.value.number+1); // revision 0 is also stored.
    285     if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, false,
    286                              log_message_receiver, static_cast<void*>(&lb),
    287                              context_, subpool)))
    288       // cleanupp will throw an exception
    289       cleanup(err, subpool, "commit_dates: svn_client_log3 failed");
    290     svn_pool_destroy(subpool);
    291     return lb.authors;
    292   }
    293 
    294 
    295   std::vector<size_t> SVN::revisions(const std::string& path)
    296   {
    297     // Allocate space in subpool to pool_ for apr_path (here a string).
    298     apr_pool_t *subpool = svn_pool_create(pool_);
    299     apr_array_header_t* apr_path=apr_array_make(subpool,1,4);
    300     // Copy path to apr_path.
    301     (*((const char **) apr_array_push(apr_path))) =
    302       apr_pstrdup(subpool, svn_path_internal_style(path.c_str(),subpool));
    303 
    304     // Setup to retrieve all commit logs.
    305     svn_opt_revision_t peg, start, head;
    306     peg.kind=svn_opt_revision_unspecified;
    307     start.kind=svn_opt_revision_number;
    308     start.value.number=0;
    309     head.kind=svn_opt_revision_head;
    310     svn_error_t* err=NULL;
    311     // Retrieving the last revision is only needed for the reserve
    312     // call below, not needed for the functionality here.
    313     if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
    314                                       subpool)))
    315       cleanup(err, subpool, "commit_dates: svn_ra_get_latest_revnum failed");
    316     // The struct we want to pass through to all log_message_receiver
    317     // calls, here we only want to push all commit dates into a
    318     // std::vector<std::string>.
    319     struct log_receiver_baton lb;
    320     lb.commit_dates.reserve(head.value.number+1); // revision 0 is also stored.
    321     lb.authors.reserve(head.value.number+1); // revision 0 is also stored.
    322     lb.rev.reserve(head.value.number+1); // revision 0 is also stored.
    323     if ((err=svn_client_log3(apr_path, &peg, &start, &head, 0, false, false,
    324                              log_message_receiver, static_cast<void*>(&lb),
    325                              context_, subpool)))
    326       // cleanupp will throw an exception
    327       cleanup(err, subpool, "commit_dates: svn_client_log3 failed");
    328     svn_pool_destroy(subpool);
    329     return lb.rev;
    330   }
    331 
    332 
    333219  void SVN::cleanup(svn_error_t *err,apr_pool_t *pool,
    334220                    const std::string& message)
     
    366252      lb->authors.push_back("");
    367253    lb->rev.push_back(rev);
     254    if (msg)
     255      lb->msg.push_back(std::string(msg));
     256    else
     257      lb->msg.push_back(std::string(""));
    368258    return SVN_NO_ERROR;
    369259  }
Note: See TracChangeset for help on using the changeset viewer.