You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Alan Knowles <al...@akbkhome.com> on 2005/04/19 05:28:54 UTC
Client library usage
I just thought I'd have a quick go at doing the php bindings for
libsvn_client, I'm baseing it on 1.1.4 and got a simple build enviroment
going ok. but running into trouble understanding all the pre-requisites
to actually run a command.
based on looking at cmdline/main.c and what looks like slightly outdated
docs at
http://www.linuxdevcenter.com/pub/a/linux/2003/04/24/libsvn1.html?page=2
I've got something like the code below (SVN_G is php's way of doing
thread safe globals BTW)
It currently segfaults on calling the checkout, I'm guessing it's due to
the lack of configuration/auth parameters.. Any pointers as to what's
missing and examples?
Thanks
Alan
Backtrace
-----------------------------------------
0x404965be in svn_auth_set_parameter () from /usr/lib/libsvn_subr-1.so.0
(gdb) up
#1 0x405c64f8 in svn_ra_dav__do_check_path ()
from /usr/lib/libsvn_ra_dav-1.so.0
(gdb) up
#2 0x4045a628 in svn_client__open_ra_session ()
from /usr/lib/libsvn_client-1.so.0
(gdb) up
#3 0x404498ed in svn_client__checkout_internal ()
from /usr/lib/libsvn_client-1.so.0
(gdb) up
#4 0x40449daf in svn_client_checkout ()
from /usr/lib/libsvn_client-1.so.0
(gdb) up
#5 0x40019026 in zif_svn_checkout (ht=0, return_value=0x8352464,
this_ptr=0x0,
Code snippet
-----------------------------------------
int
set_up_client_ctx ()
{
apr_allocator_t *allocator;
svn_error_t *err;
if (apr_allocator_create (&allocator))
return 1;
apr_allocator_max_free_set (allocator,
SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
SVN_G(pool) = svn_pool_create_ex (NULL, allocator);
apr_allocator_owner_set (allocator, SVN_G(pool));
if ((err = svn_client_create_context (&SVN_G(ctx), SVN_G(pool))))
return 1;
if ((err = svn_config_get_config (&(SVN_G(ctx)->config),
NULL, SVN_G(pool))))
return 1;
return 0;
}
........
and in the checkout bindings:
revision.kind = svn_opt_revision_head;
err = svn_client_checkout (NULL,
repos_url,
target_path,
&revision,
TRUE, /* yes, we want to recurse into the URL */
SVN_G(ctx),
SVN_G(pool));
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: Client library usage
Posted by "Peter N. Lundblad" <pe...@famlundblad.se>.
On Tue, 19 Apr 2005, Alan Knowles wrote:
> I just thought I'd have a quick go at doing the php bindings for
> libsvn_client, I'm baseing it on 1.1.4 and got a simple build enviroment
> going ok. but running into trouble understanding all the pre-requisites
> to actually run a command.
>
Just a hint: 1.2.0 is due in some weeks, so it might be a good idea to
base yur bindings on that. It adds some new APIs.
> the lack of configuration/auth parameters.. Any pointers as to what's
> missing and examples?
>
The authentication stuff is required. You can see how to set it up in the
cmdline client. You can trim it down to what you need and make it
non-interactive if you want.
Some other comments.
> Code snippet
> -----------------------------------------
>
> int
> set_up_client_ctx ()
> {
> apr_allocator_t *allocator;
> svn_error_t *err;
> if (apr_allocator_create (&allocator))
> return 1;
>
> apr_allocator_max_free_set (allocator,
> SVN_ALLOCATOR_RECOMMENDED_MAX_FREE);
>
> SVN_G(pool) = svn_pool_create_ex (NULL, allocator);
> apr_allocator_owner_set (allocator, SVN_G(pool));
>
> if ((err = svn_client_create_context (&SVN_G(ctx), SVN_G(pool))))
> return 1;
>
You need to clear any errors, else they are leaked. In debugging builds,
the application will crash at termination if the error wasn't cleared.
Same applies below.
> if ((err = svn_config_get_config (&(SVN_G(ctx)->config),
> NULL, SVN_G(pool))))
> return 1;
>
>
>
> return 0;
> }
> ........
> and in the checkout bindings:
> revision.kind = svn_opt_revision_head;
>
> err = svn_client_checkout (NULL,
> repos_url,
> target_path,
> &revision,
> TRUE, /* yes, we want to recurse into the URL */
> SVN_G(ctx),
> SVN_G(pool));
>
>
Hope I've been to some help; feel free to ask again.
Regards,
//Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org