You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Nik Clayton <ni...@ngo.org.uk> on 2006/12/06 10:18:25 UTC

Re: Named params for Perl bindings

Nik Clayton wrote:
> Nik Clayton wrote:
>>>> On 7/20/06, Nik Clayton <ni...@ngo.org.uk> wrote:
>>>>> Assuming I get the time to do the work, would anyone be
>>>>> interested in patches to the Perl bindings to support named
>>>>> parameters as well as positional parameters?
> [...]
>> 
>> OK.  Here's a proof-of-concept implementation that adjusts 
>> SVN::Client::ls() so that it can take named params (new style) or 
>> positional params (old style).
> 
> Here's an updated patch.  This one adjusts the data structure that stores
>  metadata about the parameters to each SVN::Client function to also
> include information about the method's parameter list, with a
> Params::Validate validation specification.
> 
> This is then used to support optional parameters with default values.

And the attached patch starts updating the documentation for ls(), which is
the only function modified so far.

As before, apply the patch, run "make swig-pl".

The following code should then work:

   #!/usr/bin/perl

   use strict;
   use warnings;

   use lib '/path/to/subversion/blib/lib';  # XXX adjust this as necessary
   use SVN::Client;
   use Data::Dumper;

   my $c = SVN::Client->new();
   my $u = 'file:///home/nik/.svk/svn';     # XXX adjust this as necessary

   # Old style
   print Dumper $c->ls($u, 'HEAD', 0);

   # New style
   print Dumper $c->ls({
       path_or_url => $u,
       revision    => 'HEAD',
       recurse     => 0,
   });

   # New style, revision and recurse named params both optional
   print Dumper $c->ls({ path_or_url => $u });

   # Old style, revision and recurse positional params both optional
   print Dumper $c->ls($u);

Assuming people think this is a good idea, what's the best way to proceed?

I'm happy to continue to develop this piecemeal in my SVK repo.  That'll
result in a very large patch later though.

The work's amenable to being incorporated bit-by-bit in to SVN::Client
-- although that would leave the slightly odd situation where some
functions have this functionality and others don't.

Alternatively, I'm happy to develop this on a branch in the main repo
(depending on your policy on giving commit bits out), so that it's more
visible, and easier for people to try out.

Thoughts?

N