Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "svn_client.h"
- #include "svn_cmdline.h"
- #include "svn_pools.h"
- int main(int, char *[])
- {
- svn_error_t *err = 0;
- // Init subversion.
- svn_cmdline_init( "test", stderr );
- // Crete memory pool for all ARP operations.
- apr_pool_t *pool = svn_pool_create( 0 );
- // Create subversion context for operations.
- svn_client_ctx_t* ctx = 0;
- err = svn_client_create_context( & ctx, pool );
- // Load the run-time config file into context.
- err = svn_config_get_config( & ctx->config, 0, pool );
- // Get configuration back from context.
- svn_config_t *config = (svn_config_t*)apr_hash_get
- (
- ctx->config,
- SVN_CONFIG_CATEGORY_CONFIG,
- APR_HASH_KEY_STRING
- );
- err = svn_cmdline_create_auth_baton
- (
- & ctx->auth_baton,
- // non-interactive
- TRUE,
- // username
- "username",
- // password
- "password",
- // dir to read config from
- "",
- // no auth cache
- TRUE,
- // trust server certificate
- TRUE,
- // config
- config,
- // cancel function, |svn_cancel_func_t|
- 0,
- // cancel baton, |void*|
- 0,
- // pool
- pool
- );
- svn_opt_revision_t revision;
- revision.kind = svn_opt_revision_head;
- apr_hash_t* results = 0;
- // First test: issue subversion "ls" command.
- err = svn_client_ls
- (
- & results,
- // Give non-existant URL intentionaly to get error.
- "http://wrong.url",
- & revision,
- // Recursion.
- FALSE,
- ctx,
- pool
- );
- // This will correctly display "Could not resolve hostname 'wrong.url'".
- if( err )
- {
- svn_handle_error2( err, stderr, 0, "ls: " );
- }
- apr_array_header_t* poPaths = apr_array_make( pool, 0, sizeof( char* ) );
- // Give non-existing path to get error.
- const char* pPath = apr_pstrdup( pool, "wrong path" );
- *(const char**)apr_array_push( poPaths ) = pPath;
- // Second test: issue subversion "up" command.
- err = svn_client_update3
- (
- //o Revisions.
- 0,
- //i List of target paths.
- poPaths,
- //i Revision to get.
- & oRevision,
- //i Update depth.
- svn_depth_infinity,
- //i depth is sticky.
- FALSE,
- //i ignore externals.
- TRUE,
- //i allow unversioned obstructions,
- TRUE,
- //i context.
- ctx,
- //i pool
- pool
- );
- // This will NOT work. Why? svn_client_update3() can't success with
- // non-existing path.
- if( err )
- {
- svn_handle_error2( err, stderr, 0, "update: " );
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement