10
SVN::Ra - Subversion remote access functions
16
my $ra = SVN::Ra->new ('file:///tmp/svmtest');
17
print $ra->get_latest_revnum ();
22
SVN::Ra wraps the object-oriented svn_ra_plugin_t functions.
26
=head2 CONSTRUCTOR - new (...)
28
The method creates an RA object and calls C<open> for it. It takes a
29
hash array as parameter. if there's only one argument supplied, it's
30
used as the url. valid keys are:
38
An auth_baton could be given to the SVN::RA object. Default to a
39
auth_provider with a username_provider. See L<SVN::Client> for how to
44
The pool for the ra session to use, and also the member functions will
45
be called with this pool. Default to a newly created root pool.
49
The config hash that could be obtained by SVN::Core::config_get_config(undef).
53
The ra_callback namespace to use. Default to SVN::Ra::Callback.
59
Please consult the svn_ra.h section in the Subversion API. Member
60
functions of svn_ra_plugin_t could be called as methods of SVN::Ra
61
objects, with the session_baton and pool omitted.
67
my $ralib = SVN::_Ra::svn_ra_init_ra_libs($SVN::Core::gpool);
69
# Ra methods that returns reporter
70
my %reporter = map { $_ => 1 } qw(do_diff do_switch do_status do_update);
74
my $class = ref($_[0]);
75
my $method = $AUTOLOAD;
77
return unless $method =~ m/[^A-Z]/;
82
my $func = $self->{session}->can ($method)
83
or die "no such method $method";
85
my @ret = $func->($self->{session}, @_);
86
return bless [@ret], 'SVN::Ra::Reporter' if $reporter{$method};
87
return $#ret == 0 ? $ret[0] : @ret;
92
my $self = bless {}, $class;
93
%$self = $#_ ? @_ : (url => $_[0]);
95
if (defined($self->{auth})) {
96
if (ref($self->{auth}) ne '_p_svn_auth_baton_t') {
97
# If the auth is already set to a auth_baton ignore it
98
# otherwise make an auth_baton and store the callbacks
99
my ($auth_baton,$auth_callbacks) =
100
SVN::Core::auth_open_helper($self->{auth});
101
$self->{auth} = $auth_baton;
102
$self->{auth_provider_callbacks} = $auth_callbacks;
105
# no callback to worry about with a username provider so just call
107
$self->{auth} = SVN::Core::auth_open(
108
[SVN::Client::get_username_provider()]);
111
my $pool = $self->{pool} ||= SVN::Pool->new;
112
my $callback = 'SVN::Ra::Callbacks';
114
# custom callback namespace
115
if ($self->{callback} && !ref($self->{callback})) {
116
$callback = delete $self->{callback};
118
# instantiate callbacks
119
$callback = (delete $self->{callback}) || $callback->new (auth => $self->{auth});
121
$self->{session} = SVN::_Ra::svn_ra_open ($self->{url}, $callback, $self->{config} || {}, $pool);
129
package _p_svn_ra_session_t;
130
use SVN::Base qw(Ra svn_ra_);
132
package SVN::Ra::Reporter;
133
use SVN::Base qw(Ra svn_ra_reporter2_);
135
=head1 SVN::Ra::Reporter
137
the SVN::Ra methods: do_diff, do_status, do_switch, do_update, returns
138
a SVN::Ra::Reporter object as a wrapper of svn_ra_reporter_t. You can
139
use the member functions of it as methods of SVN::Ra::Reporter, with
140
the reporter_baton omitted.
146
my $class = ref($_[0]);
147
$AUTOLOAD =~ s/^${class}::(SUPER::)?//;
148
return if $AUTOLOAD =~ m/^[A-Z]/;
153
my $method = $self->can("invoke_$AUTOLOAD")
154
or die "no such method $AUTOLOAD";
156
no warnings 'uninitialized';
157
$method->(@$self, @_);
160
package SVN::Ra::Callbacks;
162
=head1 SVN::Ra::Callbacks
164
This is the wrapper class for svn_ra_callback_t. To supply custom
165
callback to SVN::Ra, subclass this class and override the member
174
my $self = bless {}, $class;
180
local $^W; # silence the warning for unopened temp file
181
my ($self, $pool) = @_;
182
my ($fd, $name) = SVN::Core::io_open_unique_file(
183
( File::Temp::tempfile(
184
'XXXXXXXX', OPEN => 0, DIR => File::Spec->tmpdir
185
))[1], 'tmp', 1, $pool
196
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
200
Copyright (c) 2003 CollabNet. All rights reserved.
202
This software is licensed as described in the file COPYING, which you
203
should have received as part of this distribution. The terms are also
204
available at http://subversion.tigris.org/license-1.html. If newer
205
versions of this license are posted there, you may use a newer version
206
instead, at your option.
208
This software consists of voluntary contributions made by many
209
individuals. For exact contribution history, see the revision history
210
and logs, available at http://subversion.tigris.org/.