Skip to content

Instantly share code, notes, and snippets.

@vadmium
Last active January 4, 2016 11:09
Show Gist options
  • Save vadmium/8613200 to your computer and use it in GitHub Desktop.
Save vadmium/8613200 to your computer and use it in GitHub Desktop.
Demo of Subversion failure after cancellation
$ ./svn.exe
open http://gmapcatcher.googlecode.com/svn/trunk
get location segments
location segment receiver returning error 370001
location segments error 370001: Dummy message [intentional]
svn_error_clear() called
get log limit=1
log error 370001: Error running context: APR does not understand this error code child=(nil) [problem in >= 1.8.3]
[Exit 1]
$ ./svn.exe
open http://gmapcatcher.googlecode.com/svn/trunk
get location segments
location segment receiver returning error 370001
location segments error 370001: Dummy message [intentional]
svn_error_clear() called
get log limit=1
log revision 1 [working in <= 1.7.8]
get log success [working in <= 1.7.8]
/*
Compile with
gcc -Wall svn.c -o svn.exe \
-I{"$(apr-1-config --includedir)",/usr/include/subversion-1/} \
$(apr-1-config --link-ld) -lsvn_ra-1 -lsvn_subr-1
*/
#include <apr_general.h>
#include <svn_types.h>
#include <svn_ra.h>
#include <assert.h>
#include <stdio.h>
static svn_error_t* location_segment_receiver(
svn_location_segment_t* segment, void* baton, apr_pool_t* pool);
static svn_error_t* log_entry_receiver(void* baton,
svn_log_entry_t* log_entry, apr_pool_t* pool);
int main(int argc, char** argv) {
apr_pool_t* pool;
svn_error_t* err;
int ret = 0;
/* import subvertpy.ra */
apr_initialize();
assert(0 == apr_pool_create(&pool, NULL));
svn_ra_initialize(pool);
/* auth = subvertpy.ra.Auth(()) */
apr_array_header_t* providers;
providers = apr_array_make(pool, 0,
sizeof (svn_auth_provider_object_t*));
assert(providers != NULL);
svn_auth_baton_t* auth_baton;
svn_auth_open(&auth_baton, providers, pool);
char const* url;
if(argc >= 2) {
url = argv[1];
} else {
url = "http://gmapcatcher.googlecode.com/svn/trunk";
}
/* ra = RemoteAccess(url, auth=auth) */
svn_ra_callbacks2_t *callbacks2;
assert(NULL == svn_ra_create_callbacks(&callbacks2, pool));
callbacks2->auth_baton = auth_baton;
printf("open %s\n", url);
svn_ra_session_t *ra;
assert(NULL == svn_ra_open3(&ra,
url, /* uuid */ NULL, callbacks2, 0, /* config */ NULL, pool));
/* ra.get_location_segments("", -1, -1, -1, stop) */
printf("get location segments\n");
err = svn_ra_get_location_segments(ra,
"", SVN_INVALID_REVNUM, SVN_INVALID_REVNUM, SVN_INVALID_REVNUM,
location_segment_receiver, 0, pool);
assert(NULL != err);
printf("location segments error %i: %s [intentional]\n",
err->apr_err, err->message);
svn_error_clear(err);
printf("svn_error_clear() called\n");
/* ra.get_log(dummy,
strict_node_history=False, paths=None,
start=-1, end=-1, limit=1,
discover_changed_paths=True,
) */
apr_array_header_t* apr_paths = apr_array_make(pool, 1, sizeof (char*));
APR_ARRAY_PUSH(apr_paths, char*) = apr_pstrdup(pool, "");
apr_array_header_t *apr_revprops = NULL;
printf("get log limit=1\n");
err = svn_ra_get_log2(ra,
apr_paths, /* start */ 1,
/* end */ SVN_INVALID_REVNUM, /* limit */ 1,
/* discover_changed_paths */ FALSE, /* strict_node_history */ FALSE,
/* include_merged_revisions */ FALSE, apr_revprops,
log_entry_receiver, 0, pool);
if(NULL == err) {
printf("get log success [working in <= 1.7.8]\n");
} else {
printf("log error %i: %s child=%p [problem in >= 1.8.3]\n",
err->apr_err, err->message, err->child);
svn_error_clear(err);
ret = 1;
}
/* del provider, auth, ra */
apr_pool_destroy(pool);
return ret;
}
static svn_error_t* location_segment_receiver(
svn_location_segment_t* segment, void* baton, apr_pool_t* pool) {
/* raise */
printf("location segment receiver returning error 370001\n");
return svn_error_create(370001, NULL, "Dummy message");
}
static svn_error_t* log_entry_receiver(void* baton,
svn_log_entry_t* log_entry, apr_pool_t* pool) {
printf("log revision %li [working in <= 1.7.8]\n", log_entry->revision);
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment