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

Perl API SVN::Ra::get_commit_editor2 causes TypeError

From: Markus Kuhn <Markus.Kuhn_at_cl.cam.ac.uk>
Date: Fri, 09 Jul 2010 23:24:38 +0100

I'm trying to commit a file modification in a Subversion repository from
within a Perl CGI script, and the Perl SVN:Ra API looks like the right tool
for doing that, but I have early on run into a problem:

Using subversion-perl-1.5.7 (from openSUSE Linux 11.1), the test program

#!/usr/bin/perl
use SVN::Core;
use SVN::Ra;
use SVN::Delta;
my $ra = SVN::Ra->new('http://core.svn.wordpress.org/');
my $logmsg = "test commit via the SVN:Ra Perl API";
sub commit_callback {
    my ($arg) = @_;
    use Data::Dumper;
    print STDERR "commit_callback(".Dumper($arg).")\n";
}
my $editor = SVN::Delta::Editor->new(
    $ra->get_commit_editor2($logmsg, \&commit_callback, undef, {}, 0));

results in the error message

  TypeError in method 'svn_ra_get_commit_editor2', argument 5 of type 'svn_commit_callback2_t'

being printed.

Any idea what I am doing wrong?

I had thought, the last lines follow closely the example given in "man SVN::Ra":

       $ra->get_commit_editor($logmsg, $callback, $callback_baton, $lock_tokens, $keep_locks)
       $ra->get_commit_editor2($logmsg, $callback, $callback_baton, $lock_tokens, $keep_locks)
           Return an opaque editor object for committing a new revision to the repository. The
           return values should be passed to the SVN::Delta::Editor constructor to create an
           editor object you can actually use. For example:

               my $editor = SVN::Delta::Editor->new(
                   $ra->get_commit_editor(
                       "I'm going to commit some changes from within my Perl code.",
                       \&commit_callback, undef, {}, 0));

           Now that you've got your editor you can call methods on it to describe changes in the
           tree you want to make, such as adding directories, changing file contents, etc. See
           SVN::Delta for documentation of the editor interface.

           The $callback function will be called during your call to the "$ed->close_edit()"
           method, after the commit has succeeded. It will not be called if there were no
           changes to commit. If you don't need it, pass undef instead of a code ref.

           "get_commit_editor2" is identical to "get_commit_editor" except for the information
           passed to the callback function. The new version, added in Subversion 1.4, will pass
           the callback a single value (TODO: I can' test this, but it's probably an object or
           hash ref) which contains all the information. It also includes the error message
           from the post-commit hook script, which is not available with "get_commit_editor".

(The last TODO sentences above worry me somewhat: is this API actually ready for production use?)

Markus

-- 
Markus Kuhn, Computer Laboratory, University of Cambridge
http://www.cl.cam.ac.uk/~mgk25/ || CB3 0FD, Great Britain
Received on 2010-07-10 06:53:33 CEST

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

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