📄 ra.pm
字号:
use strict;use warnings;package SVN::Ra;use SVN::Base qw(Ra);use File::Temp;=head1 NAMESVN::Ra - Subversion remote access functions=head1 SYNOPSIS require SVN::Core; require SVN::Ra; my $ra = SVN::Ra->new ('file:///tmp/svmtest'); print $ra->get_latest_revnum ();=head1 DESCRIPTIONSVN::Ra wraps the object-oriented svn_ra_plugin_t functions.=head1 SVN::Ra=head2 CONSTRUCTOR - new (...)The method creates an RA object and calls C<open> for it. It takes ahash array as parameter. if there's only one argument supplied, it'sused as the url. valid keys are:=over=item url=item authAn auth_baton could be given to the SVN::RA object. Default to aauth_provider with a username_provider. See L<SVN::Client> for how tocreate auth_baton.=item poolThe pool for the ra session to use, and also the member functions willbe called with this pool. Default to a newly created root pool.=item configThe config hash that could be obtained by SVN::Core::config_get_config(undef).=item callbackThe ra_callback namespace to use. Default to SVN::Ra::Callback.=back=head2 METHODSPlease consult the svn_ra.h section in the Subversion API. Memberfunctions of svn_ra_plugin_t could be called as methods of SVN::Raobjects, with the session_baton and pool omitted.=cutrequire SVN::Client;my $ralib = SVN::_Ra::svn_ra_init_ra_libs($SVN::Core::gpool);# Ra methods that returns reportermy %reporter = map { $_ => 1 } qw(do_diff do_switch do_status do_update);our $AUTOLOAD;sub AUTOLOAD { my $class = ref($_[0]); my $method = $AUTOLOAD; $method =~ s/.*:://; return unless $method =~ m/[^A-Z]/; my $self = shift; no strict 'refs'; my $func = $self->{session}->can ($method) or die "no such method $method"; my @ret = $func->($self->{session}, @_); return bless [@ret], 'SVN::Ra::Reporter' if $reporter{$method}; return $#ret == 0 ? $ret[0] : @ret;}sub new { my $class = shift; my $self = bless {}, $class; %$self = $#_ ? @_ : (url => $_[0]); if (defined($self->{auth})) { if (ref($self->{auth}) ne '_p_svn_auth_baton_t') { # If the auth is already set to a auth_baton ignore it # otherwise make an auth_baton and store the callbacks my ($auth_baton,$auth_callbacks) = SVN::Core::auth_open_helper($self->{auth}); $self->{auth} = $auth_baton; $self->{auth_provider_callbacks} = $auth_callbacks; } } else { # no callback to worry about with a username provider so just call # auth_open directly $self->{auth} = SVN::Core::auth_open( [SVN::Client::get_username_provider()]); } my $pool = $self->{pool} ||= SVN::Pool->new; my $callback = 'SVN::Ra::Callbacks'; # custom callback namespace if ($self->{callback} && !ref($self->{callback})) { $callback = delete $self->{callback}; } # instantiate callbacks $callback = (delete $self->{callback}) || $callback->new (auth => $self->{auth}); $self->{session} = SVN::_Ra::svn_ra_open ($self->{url}, $callback, $self->{config} || {}, $pool); return $self;}sub DESTROY {}package _p_svn_ra_session_t;use SVN::Base qw(Ra svn_ra_);package SVN::Ra::Reporter;use SVN::Base qw(Ra svn_ra_reporter2_);=head1 SVN::Ra::Reporterthe SVN::Ra methods: do_diff, do_status, do_switch, do_update, returnsa SVN::Ra::Reporter object as a wrapper of svn_ra_reporter_t. You canuse the member functions of it as methods of SVN::Ra::Reporter, withthe reporter_baton omitted.=cutour $AUTOLOAD;sub AUTOLOAD { my $class = ref($_[0]); $AUTOLOAD =~ s/^${class}::(SUPER::)?//; return if $AUTOLOAD =~ m/^[A-Z]/; my $self = shift; no strict 'refs'; my $method = $self->can("invoke_$AUTOLOAD") or die "no such method $AUTOLOAD"; no warnings 'uninitialized'; $method->(@$self, @_);}package SVN::Ra::Callbacks;=head1 SVN::Ra::CallbacksThis is the wrapper class for svn_ra_callback_t. To supply customcallback to SVN::Ra, subclass this class and override the memberfunctions.=cutrequire SVN::Core;sub new { my $class = shift; my $self = bless {}, $class; %$self = @_; return $self;}sub open_tmp_file { local $^W; # silence the warning for unopened temp file my ($self, $pool) = @_; my ($fd, $name) = SVN::Core::io_open_unique_file( ( File::Temp::tempfile( 'XXXXXXXX', OPEN => 0, DIR => File::Spec->tmpdir ))[1], 'tmp', 1, $pool ); return $fd;}sub get_wc_prop { return undef;}=head1 AUTHORSChia-liang Kao E<lt>clkao@clkao.orgE<gt>=head1 COPYRIGHTCopyright (c) 2003 CollabNet. All rights reserved.This software is licensed as described in the file COPYING, which youshould have received as part of this distribution. The terms are alsoavailable at http://subversion.tigris.org/license-1.html. If newerversions of this license are posted there, you may use a newer versioninstead, at your option.This software consists of voluntary contributions made by manyindividuals. For exact contribution history, see the revision historyand logs, available at http://subversion.tigris.org/.=cut1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -