You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Markus Kuhn <Ma...@cl.cam.ac.uk> on 2010/07/09 22:24:38 UTC
Perl API SVN::Ra::get_commit_editor2 causes TypeError
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
Re: Perl API SVN::Ra::get_commit_editor2 causes TypeError
Posted by yary <no...@gmail.com>.
Just a stab in the dark, what version of Subversion do you have on
that box? It looks like this perl module comes bundles with Subversion
1.4 and some users have complained that it doesn't first check to see
if there is a subverison installed for it to use. It also looks like
that module was last updated in 2007.
So perhaps it isn't good for production use :-( If you really do need
SVN::Core working, you might need to compile it from source and not
use a distro. I haven't used that module myself though and am not even
sure that is the issue.
Depending on your needs, this may work-
http://search.cpan.org/~karman/SVN-Class-0.16/lib/SVN/Class.pm
SVN::Class uses your svn binary to reduce dependencies. It was last
updated a couple months ago, and looks like it has a clean syntax.
-y