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

Re: Perl API SVN::Ra::get_commit_editor2 causes TypeError

From: Markus Kuhn <Markus.Kuhn_at_cl.cam.ac.uk>
Date: Sun, 11 Jul 2010 15:14:11 +0100

yary wrote on 2010-07-11 00:03 UTC:
> Just a stab in the dark, what version of Subversion do you have on
> that box?

I was initially using SVN::Ra from Subversion 1.5.7, as shipping with
openSUSE Linux 11.1.

I've since also tried to use the come shipping with openSUSE 11.2,
which has Subversion 1.6.6: exact same result.

Note that other parts of SVN:Ra do work fine for me, e.g. I can use

  #!/usr/bin/perl
  use SVN::Core;
  use SVN::Ra;
  use SVN::Delta;

  my $ra = SVN::Ra->new('http://svn.apache.org/repos/asf/subversion/');
  my $path = 'trunk/BUGS';
  open($fh, '>', \$text) || die;
  my ($revnum, $props) = $ra->get_file($path, $SVN::Core::INVALID_REVNUM, $fh);
  close $fh || die;
  print "Revision: $revnum\n\n$text\n";

without any problem to load the content of a file from a repository into
a local Perl variable $text.

The only (but crucial) thing that I couldn't get to work so far is

  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));

which results in

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

I also get a similar TypeError message when I try get_commit_editor
instead of get_commit_editor2. (However, I really would like to use
get_commit_editor2, as get_commit_editor is said not to provide access
to error messages from the post-commit hook script on the server,
which I do need in my application.)

> 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.

The openSUSE RPM package management takes care that this can't happen:
the subversion package is a requirement of the subversion-perl package.

> It also looks like that module was last updated in 2007.

In case

  svn cat http://svn.apache.org/repos/asf/subversion/trunk/subversion/bindings/swig/perl/native/t/6ra.t

shows the official test suite for the Perl SVN::Ra binding, then it is
of some concern that it does not appear to contain any tests for either
get_commit_editor or get_commit_editor2. :-(

> 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.

Thanks for the pointer, but I doubt that is what I am looking for.

My application: I would like to write a CGI script that offers a
web-interface editor for a file stored in a Subversion repository.

Problem: In CGI scripts, having to check out a working copy is extremely
inconvenient. Instead, I would like to fetch the content of a file into
a Perl variable, edit it there, and then commit the changed version it
back to the repository, without the content of the file ever touching
the local file system. As far as I understand, the "svn" command-line
does not allow me to do this.

That is why I would like to use the remote-access layer API from Perl
(SVN:Ra), which sits underneath the Client layer that manages working
copies. Sadly, it looks increasingly like that part of the Perl binding
has not been tested completely.

May be, I should try the equivalent Python binding (svn.ra) instead,
which at least appears to call the relevant get_commit_editor* functions
in their test collection bindings/swig/python/tests/ra.py.

Markus

-- 
Markus Kuhn, Computer Laboratory, University of Cambridge
http://www.cl.cam.ac.uk/~mgk25/ || CB3 0FD, Great Britain
Received on 2010-07-11 16:18:00 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.