[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Making a simple svn client

From: Timothy Place <tim_at_electrotap.com>
Date: 2006-11-15 07:34:42 CET

Hi...

I am trying to make a very simple svn client which basically just
does one thing: a fresh svn checkout from a fixed url. For example,
in the code at the end of this email I am attempting to do the
equivalent of this command line:
        svn co https://svn.sourceforge.net/svnroot/ttblue/trunk/ttblue/dsplib/
        
I just want to do a checkout on program startup, then the program
ends. It is from sourceforge, meaning no username or password are
required. I don't need any sort of progress reporting. I am
building off of 1.3.x libraries.

The problem that I am having is that when I get to the bottom, the
checkout fails with an error like so:
        PROPFIND request failed on '/svnroot/ttblue/trunk/ttblue/dsplib'
I seem to be doing something wrong, but I'm not sure what that is.
Can anyone lend me a hand?

Many thanks,
    Tim

{
        svn_auth_provider_object_t *username_wc_provider;
        apr_array_header_t *providers;
        svn_auth_baton_t *ab;
        svn_config_t *cfg;
        apr_allocator_t *allocator;
        apr_pool_t *pool;
        apr_pool_t *subpool;
        apr_array_header_t *received_opts;
        svn_client_ctx_t *ctx;
        svn_error_t *err;
        svn_revnum_t result_rev;
        svn_opt_revision_t revision;
        
        apr_initialize();
        
        // Create our top-level pool. Use a seperate mutexless allocator,
        // given this application is single threaded.
        if(apr_allocator_create(&allocator))
                error("EXIT_FAILURE");

        apr_allocator_max_free_set(allocator,
SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
        pool = svn_pool_create_ex(NULL, allocator);
        apr_allocator_owner_set(allocator, pool);
        received_opts = apr_array_make(pool, SVN_OPT_MAX_OPTIONS, sizeof(int));
        
        err = svn_ra_initialize(pool);
        if(err)
                error("svn_ra_initialize(pool) FAILED");
                
        svn_client_create_context(&ctx, pool);

        err = svn_config_get_config(&(ctx->config), NULL, pool);
        if(err)
                error("svn_config_get_config() FAILED");
                
        cfg = (svn_config_t *)apr_hash_get(ctx->config,
SVN_CONFIG_CATEGORY_CONFIG, APR_HASH_KEY_STRING);
                
        providers = apr_array_make(pool, 1, sizeof
(svn_auth_provider_object_t *));
        username_wc_provider = (svn_auth_provider_object_t *)apr_pcalloc
(pool, sizeof(*username_wc_provider));
        svn_client_get_username_provider(&username_wc_provider, pool);
        *(svn_auth_provider_object_t **)apr_array_push(providers) =
username_wc_provider;

        // Build an authentication baton to give to libsvn_client.
        svn_auth_open(&ab, providers, pool);

        // Place any default --username or --password credentials into the
auth_baton's run-time parameter hash.
        svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_USERNAME, "");
        svn_auth_set_parameter(ab, SVN_AUTH_PARAM_DEFAULT_PASSWORD, "");
        svn_auth_set_parameter(ab, SVN_AUTH_PARAM_NON_INTERACTIVE, "");
        svn_auth_set_parameter(ab, SVN_AUTH_PARAM_NO_AUTH_CACHE, "");

        ctx->auth_baton = ab;

        subpool = svn_pool_create(pool);
        svn_pool_clear(subpool);

        revision.kind = svn_opt_revision_head;

        err = svn_client_checkout(
                        NULL,
                        "https://svn.sourceforge.net/svnroot/ttblue/trunk/ttblue/dsplib/",
                        "/Users/tim/",
                        &revision,
                        TRUE,
                        ctx,
                        subpool);

        if(err){
                error("svn_client_checkout error: %s", err->message);
        }
        svn_pool_destroy(subpool);
                        
        apr_terminate();
}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 15 07:34:58 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.