Changeset 185 for trunk/lib/SVN.cc


Ignore:
Timestamp:
Sep 6, 2006, 4:39:18 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #65 and #60. Added support for svndigest:ignore. Uppdated documentation. Reworked binary file treatment.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/SVN.cc

    r164 r185  
    2424#include "SVN.h"
    2525
     26#include <map>
    2627#include <string>
     28#include <vector>
    2729
    2830#include <apr_allocator.h>
     
    3335#include <subversion-1/svn_pools.h>
    3436#include <subversion-1/svn_wc.h>
     37#include <subversion-1/svn_subst.h>
    3538
    3639namespace theplu {
     
    129132                                       subpool);
    130133    if (err && err->apr_err!=SVN_ERR_CLIENT_IS_BINARY_FILE) {
    131       svn_handle_error2(err, stderr, false, "svndigest: ");
    132       svn_error_clear(err);
    133       svn_pool_destroy(subpool);
     134      cleanup(err,subpool);
    134135      throw SVNException("SVN::client_blame: svn_client_blame3 failed");
    135136    }
     
    145146    if (svn_error_t *err=svn_client_info(path.c_str(), NULL, NULL, receiver,
    146147                                         baton, false, context_, subpool)) {
    147       svn_handle_error2(err, stderr, false, "svndigest: ");
    148       svn_error_clear(err);
    149       svn_pool_destroy(subpool);
     148      cleanup(err,subpool);
    150149      throw SVNException("repository: svn_client_info failed");
     150    }
     151    svn_pool_destroy(subpool);
     152  }
     153
     154
     155  void SVN::client_proplist(const std::string& path,
     156                            std::map<std::string, std::string>& property)
     157  {
     158    svn_opt_revision_t peg, revision;
     159    peg.kind=svn_opt_revision_unspecified;
     160    revision.kind=svn_opt_revision_head;
     161    apr_pool_t *subpool = svn_pool_create(pool_);
     162    apr_array_header_t * properties;
     163    svn_error_t *err=svn_client_proplist2(&properties, path.c_str(), &peg,
     164                                          &revision, false, context_, subpool);
     165    if (err) {
     166      cleanup(err,subpool);
     167      throw SVNException("repository: svn_client_proplist2 failed");
     168    }
     169    for (int j = 0; j < properties->nelts; ++j) {
     170      svn_client_proplist_item_t *item =
     171        ((svn_client_proplist_item_t **)properties->elts)[j];
     172      for (apr_hash_index_t *hi = apr_hash_first(subpool, item->prop_hash); hi;
     173           hi = apr_hash_next (hi)) {
     174        const void *key;
     175        void *val;
     176        apr_hash_this (hi, &key, NULL, &val);
     177        svn_string_t *value;
     178        err=svn_subst_detranslate_string(&value,
     179                                         static_cast<const svn_string_t*>(val),
     180                                         false, subpool);
     181        if (err) {
     182          cleanup(err,subpool);
     183          throw SVNException("property: svn_subst_detranslate_string failed");
     184        }
     185        property[static_cast<const char*>(key)]=value->data;
     186      }
    151187    }
    152188    svn_pool_destroy(subpool);
     
    174210    if ((err=svn_ra_get_latest_revnum(ra_session_, &(head.value.number),
    175211                                      subpool))) {
    176       svn_handle_error2(err, stderr, false, "svndigest: ");
    177       svn_error_clear(err);
    178       svn_pool_destroy(subpool);
     212      cleanup(err,subpool);
    179213      throw SVNException("commit_dates: svn_ra_get_latest_revnum failed");
    180214    }
     
    187221                             log_message_receiver, static_cast<void*>(&lb),
    188222                             context_, subpool))) {
    189       svn_handle_error2(err, stderr, false, "svndigest: ");
    190       svn_error_clear(err);
    191       svn_pool_destroy(subpool);
     223      cleanup(err,subpool);
    192224      throw SVNException("commit_dates: svn_client_log3 failed");
    193225    }
     
    197229
    198230
    199   void SVN::cleanup_failed_initialization(svn_error_t *err)
     231  void SVN::cleanup(svn_error_t *err,apr_pool_t *pool)
    200232  {
    201233    svn_handle_error2(err,stderr,false,"svndigest:");
    202234    svn_error_clear(err);
    203     svn_pool_destroy(pool_);
     235    svn_pool_destroy(pool);
     236  }
     237
     238
     239  void SVN::cleanup_failed_initialization(svn_error_t *err)
     240  {
     241    cleanup(err,pool_);
    204242    apr_allocator_destroy(allocator_);
    205243  }
     
    224262    if (svn_error_t *err=svn_client_open_ra_session(&ra_session_, path.c_str(),
    225263                                                    context_,pool_)) {
     264      // cleanup could be called if a null pool can be passed to
     265      // svn_pool_destroy (which is just a #define to apr_pool_destroy
    226266      svn_handle_error2(err,stderr,false,"svndigest:");
    227267      svn_error_clear(err);
     
    239279                                          false, -1, context_->cancel_func,
    240280                                          context_->cancel_baton, pool_)) {
     281      // cleanup could be called if a null pool can be passed to
     282      // svn_pool_destroy (which is just a #define to apr_pool_destroy
    241283      svn_handle_error2(err,stderr,false,"svndigest:");
    242284      svn_error_clear(err);
     
    253295        svn_wc_status2(&status,svn_path_internal_style(path.c_str(), subpool),
    254296                       adm_access_, subpool)) {
    255       svn_handle_error2(err,stderr,false,"svndigest:");
    256       svn_error_clear(err);
    257       svn_pool_destroy(subpool);
     297      cleanup(err,subpool);
    258298      throw SVNException("version_controlled(): svn_config_get_config failed");
    259299    }
Note: See TracChangeset for help on using the changeset viewer.