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

setting ra_callbacks.open_tmp_file from python bindings?

From: Gregory (Grisha) Trubetskoy <grisha_at_apache.org>
Date: 2006-05-23 22:25:45 CEST

First - pardon my subversion python bindings newbieness!!!

This is subversion 1.3.1.

I am attempting to "do stuff" with a repository using 'ra'. For starters trying
to add a file. There are plenty of examples of doing this with 'fs', but I want
'ra', because I want to be able to talk to a remote server.

So it looks like in order for delta.editor_invoke_apply_textdelta() to work,
the open_tmp_file needs to be set in the callbacks, or you will get a segfault
in:

subversion/libsvn_ra_dav/commit.c:1339

   /* Use the client callback to create a tmpfile. */
   SVN_ERR(file->cc->ras->callbacks->open_tmp_file
           (&baton->tmpfile,
            file->cc->ras->callback_baton,
            file->pool));

...because file->cc->ras->callbacks->open_tmp_file is null, unless you set it
to something.

But can you set it from python? I tried (based on a comment I saw in swig
bindings somewhere):

ra_callbacks = ra.svn_ra_callbacks_t()
ra_callbacks.open_tmp_file = core.svn_io_open_unique_file

but that fails with:

TypeError: argument number 2: a 'svn_error_t *(*)(apr_file_t **,void
*,apr_pool_t *)' is expected, 'function(<function svn_io_open_unique_file at
0xb759810c>)' is received

For more detail, here's what I'm doind in an attempt to just add a file (much
of this based on looking at viewvc code):

from svn import fs, repos, core, ra, client, delta

ROOT = "http://172.17.1.6/repos/REPO/blah"

ctx = client.svn_client_ctx_t()
providers = []
# skipping other providers for simplicity
providers.append(client.svn_client_get_username_provider())
ctx.auth_baton = core.svn_auth_open(providers)

ra_callbacks = ra.svn_ra_callbacks_t()
ra_callbacks.auth_baton = ctx.auth_baton
#ra_callbacks.open_tmp_file = ####### <--- what to do?
ra_session = ra.svn_ra_open(ROOT, ra_callbacks, None,
                             ctx.config)

rev = ra.svn_ra_get_latest_revnum(ra_session)

x = ra.svn_ra_get_commit_editor(ra_session,
                             "test log message",
                             None, # don't need anything called when we're done
                             None, # no callback baton either
                             None, # no lock-tokens
                             0) # do not keep locks
editor, edit_baton = x

# we want a new file file in /trunk/script/

root_baton = delta.editor_invoke_open_root(editor, edit_baton, rev)
trunk_baton = delta.editor_invoke_open_directory(editor, 'trunk', root_baton,
rev)
script_baton = delta.editor_invoke_open_directory(editor, 'script',
trunk_baton, rev)

new_file = delta.editor_invoke_add_file(editor, 'grisha.txt', script_baton,
None, rev)

# this is where it segfaults in subversion/libsvn_ra_dav/commit.c:1339
handler, handler_baton = delta.editor_invoke_apply_textdelta(editor, new_file,
None)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue May 23 22:26:11 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.