SVN-Mirror
view release on metacpan or search on metacpan
t/test_repo.dump view on Meta::CPAN
next SYMBOL if ("$prefix$ignored_symbol" eq $name);
}
# insert the accessor
if (m/(.*)_get$/) {
my $member = $1;
*{"${caller}::$1"} = sub {
&{"SVN::_${pkg}::${prefix}${member}_".
(@_ > 1 ? 'set' : 'get')} (@_)
}
}
elsif (m/(.*)_set$/) {
}
else {
*{"${caller}::$_"} = ${"SVN::_${pkg}::"}{$name};
}
}
}
=head1 AUTHORS
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
=head1 COPYRIGHT
Copyright (c) 2003 CollabNet. All rights reserved.
This software is licensed as described in the file COPYING, which you
should have received as part of this distribution. The terms are also
available at http://subversion.tigris.org/license-1.html. If newer
versions of this license are posted there, you may use a newer version
instead, at your option.
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
and logs, available at http://subversion.tigris.org/.
=cut
1;
Node-path: svnperl/perl/Client.pm
Node-kind: file
Node-action: add
Prop-content-length: 35
Text-content-length: 15544
Text-content-md5: a70873df186fb9dda0c7b4f102f58e78
Content-length: 15579
K 12
svn:keywords
V 2
Id
PROPS-END
use SVN::Core;
package SVN::Client;
use SVN::Base(qw(Client svn_client_ checkout update switch add mkdir delete
commit status log blame diff merge cleanup relocate
revert resolved copy move revprop_set propset
proplist revvprop_list export ls cat import));
=head1 NAME
SVN::Client - Subversion client functions
=head1 SYNOPSIS
use SVN::Client;
my $ctx = new SVN::Client(
auth => [SVN::Client::get_simple_provider(),
SVN::Client::get_simple_prompt_provider(\&simple_prompt,2),
SVN::Client::get_username_provider()]
);
$ctx->cat (\*STDOUT, 'http://svn.collab.net/repos/svn/trunk/README',
'HEAD');
sub simple_prompt {
my $cred = shift;
my $realm = shift;
my $default_username = shift;
my $may_save = shift;
my $pool = shift;
print "Enter authentication info for realm: $realm\n";
print "Username: ";
my $username = <>;
chop($username);
$cred->username($username);
print "Password: ";
my $password = <>;
chomp($password);
$cred->password($password);
}
=head1 DESCRIPTION
SVN::Client wraps the highest level of functions provided by
subversion to accomplish specific tasks in an object oriented API.
Methods are similar to the functions provided by the C API and
as such the documentation for it may be helpful in understanding
this interface.
There are a few notable differences from the C API. Most C function
calls take a svn_client_ctx_t pointer as the next to last parameter.
The perl method calls take a SVN::Client object as the first parameter.
This allows method call invocation of the methods to be possible.
Many of the C API calls also take a apr_pool_t pointer as their last
argument. The Perl bindings generally deal with this for you and
you do not need to pass a pool parameter. However, you may still
pass a pool parameter as the last parameter to override the automatic
handling of this for you.
Users of this interface should not directly manipulate the underlying hash
values but should use the respective attribute methods. Many of these
attribute methods do other things, especially when setting an attribute,
besides simply manipulating the value in the hash.
t/test_repo.dump view on Meta::CPAN
pool A new pool is created for the context.
=cut
sub new
{
my $class = shift;
my $self = bless {}, $class;
my %args = @_;
$self->{'ctx'} = SVN::_Client::new_svn_client_ctx_t ();
if (defined($args{'auth'}))
{
$self->auth($args{'auth'});
} else {
$self->auth([SVN::Client::get_username_provider(),
SVN::Client::get_simple_provider(),
SVN::Client::get_ssl_server_trust_file_provider(),
SVN::Client::get_ssl_client_cert_file_provider(),
SVN::Client::get_ssl_client_cert_pw_file_provider(),
]);
}
{
my $pool_type = ref($args{'pool'});
if ($pool_type eq 'SVN::Pool' ||
$pool_type eq '_p_apr_pool_t')
{
$self->{'pool'} = $args{'pool'};
} else {
$self->{'pool'} = new SVN::Pool();
}
}
# If we're passed a config use it, otherwise get the default
# config.
if (defined($args{'config'}))
{
if (ref($args{'config'}) eq 'HASH')
{
$self->config($args{'config'});
}
} else {
$self->config(SVN::Core::config_get_config(undef));
}
return $self;
}
=item $ctx->cat(\*FILEHANDLE, path_or_url, revision, pool);
Outputs the content of the file identified by path_or_url and revision to the
FILEHANDLE. FILEHANLDE is a reference to a filehandle. revision should be a
number or 'HEAD'. pool is an optional parameter.
=cut
# import methods into our name space and wrap them in a closure
# to support method calling style $ctx->log()
foreach my $function (qw(checkout update switch add mkdir delete commit
status log blame diff merge cleanup relocate
revert resolved copy move revprop_set propset
proplist revvprop_list export ls cat import))
{
my $real_function = \&{"SVN::_Client::svn_client_$function"};
*{"SVN::Client::$function"} = sub
{
# Allows import to work while not breaking use SVN::Client.
if ($function eq 'import')
{
if (ref($_[$[]) ne 'SVN::Client')
{
return;
}
}
my $self = shift;
my @args;
if (ref($_[$#_]) eq '_p_apr_pool_t')
{
# if we got a pool pased to us we need to
# leave it off until we add the ctx first
# so we push only the first arg to the next
# to last arg.
push @args, @_[$[ .. ($#_ - 1)];
unless ($function eq 'propset')
{
# propset doesn't take a ctx argument
push @args, $self->{'ctx'};
}
push @args, $_[$#_];
} else {
push @args, @_;
unless ($function eq 'propset')
{
push @args,$self->{'ctx'};
}
if (defined($self->{'pool'}) &&
ref($self->{'pool'}) eq '_p_apr_pool_t')
{
# allow the pool entry in the SVN::Client
# object to override the default pool.
push @args, $self->{'pool'};
}
}
return $real_function->(@args);
}
}
=head1 ATTRIBUTE METHODS
The following attribute methods are provided that allow you to set various
configuration or retrieve it. They all take value(s) to set the attribute and
return the new value of the attribute or no paremeters which reuturns the
current value.
=item $ctx->auth(SVN::Client::get_username_provider());
Provides access the auth_baton in the svn_client_ctx_t attached to the
( run in 0.988 second using v1.01-cache-2.11-cpan-524268b4103 )