Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/perl/native/Ra.pm view on Meta::CPAN
after C<$low_water_mark>, up to revision C<$revnum>. This is like using
C<do_update()>, except that it doesn't return a reporter object, and so
you don't have to describe a working copy to it. It assumes that you've
already got everything up to C<$low_water_mark>.
If C<$send_deltas> is true then file contents and property values will
be supplied, otherwise just filename changes.
New in S<Subversion 1.4>.
=item $ra-E<gt>rev_prop($revnum, $name)
Return the value of the unversioned property C<$name> from revision C<$revnum>.
Returns undef if there is no such property.
print $ra->rev_prop(123, 'svn:date');
=item $ra-E<gt>rev_proplist($revnum)
Returns a reference to a hash containing all the unversioned properties
of revision C<$revnum>.
my $props = $ra->rev_proplist(123);
print $props->{'svn:log'};
=item $ra-E<gt>stat($path, $revnum)
Returns a L<_p_svn_dirent_t|SVN::Core/_p_svn_dirent_t> object containing
information about the file at C<$path> in revision C<$revnum>.
=item $ra-E<gt>unlock(\%path_tokens, $break_lock, \&callback)
TODO - doesn't seem to work in Subversion 1.3.2
=back
=cut
require SVN::Client;
my $ralib = SVN::_Ra::svn_ra_init_ra_libs(SVN::Core->gpool);
# Ra methods that returns reporter
my %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}, @_);
# XXX - is there any reason not to use \@ret in this line:
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::Reporter
The L<SVN::Ra> methods C<do_diff>, C<do_status>, C<do_switch>, and
C<do_update> all return a SVN::Ra::Reporter object, which can be used
to describe the working copy (or other available data) which the client has.
Subversion uses this to figure out what new information should be provided
through a tree delta editor.
Objects of this class are actually simple wrappers around underlying
C<svn_ra_reporter2_t> objects and their associated baton.
=head2 METHODS
=over
=item $reporter-E<gt>set_path($path, $revision, $start_empty, $lock_token, $pool)
Describe a working copy C<$path> as being at a particular C<$revision>.
If C<$start_empty> is true and C<$path> is a directory, the
src/subversion/subversion/bindings/swig/perl/native/Ra.pm view on Meta::CPAN
(relative to the root of the report driver) isn't a reflection of
C<$path> in the repository (relative to the URL specified when
opening the RA layer), but is instead a reflection of a different
repository C<$url> at C<$revision>.
If C<$start_empty> is true and C<$path> is a directory,
the implementor should assume the directory has no entries or props.
If C<$lock_token> is not undef, it is the lock token for C<$path> in the WC.
All temporary allocations are done in C<$pool>.
=item $reporter-E<gt>finish_report($pool)
Call this when the state report is finished; any directories
or files not explicitly 'set' are assumed to be at the
baseline revision originally passed into C<do_update()>. No other
reporting functions, including C<abort_report()>, should be called after
calling this function.
=item $reporter-E<gt>abort_report($pool)
If an error occurs during a report, this method should cause the
filesystem transaction to be aborted and cleaned up. No other reporting
methods should be called after calling this method.
=back
=cut
our $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::Callbacks
This is the wrapper class for C<svn_ra_callback_t>. To supply custom
callbacks to SVN::Ra, subclass this class and override the member
functions.
=cut
require 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 AUTHORS
Chia-liang Kao E<lt>clkao@clkao.orgE<gt>
=head1 COPYRIGHT
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
=cut
1;
( run in 1.864 second using v1.01-cache-2.11-cpan-39bf76dae61 )