sub ra {
my ($self) = shift;
- $self->{ra} ||= Git::SVN::Ra->new($self->{url});
+ Git::SVN::Ra->new($self->{url});
}
sub rel_path {
sub traverse_ignore {
my ($self, $fh, $path, $r) = @_;
$path =~ s#^/+##g;
- my ($dirent, undef, $props) = $self->ra->get_dir($path, $r);
+ my $ra = $self->ra;
+ my ($dirent, undef, $props) = $ra->get_dir($path, $r);
my $p = $path;
- $p =~ s#^\Q$self->{ra}->{svn_path}\E/##;
+ $p =~ s#^\Q$ra->{svn_path}\E/##;
print $fh length $p ? "\n# $p\n" : "\n# /\n";
if (my $s = $props->{'svn:ignore'}) {
$s =~ s/[\r\n]+/\n/g;
sub full_url {
my ($self) = @_;
- $self->ra->{url} . (length $self->{path} ? '/' . $self->{path} : '');
+ $self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
}
sub do_git_commit {
use strict;
use warnings;
my ($can_do_switch);
-my %RA;
+my $RA;
BEGIN {
# enforce temporary pool usage for some simple functions
sub new {
my ($class, $url) = @_;
$url =~ s!/+$!!;
- return $RA{$url} if $RA{$url};
+ return $RA if ($RA && $RA->{url} eq $url);
SVN::_Core::svn_config_ensure($config_dir, undef);
my ($baton, $callbacks) = SVN::Core::auth_open_helper([
$self->{svn_path} = $url;
$self->{repos_root} = $self->get_repos_root;
$self->{svn_path} =~ s#^\Q$self->{repos_root}\E/*##;
- $RA{$url} = bless $self, $class;
+ $RA = bless $self, $class;
}
sub DESTROY {
- # do not call the real DESTROY since we store ourselves in %RA
+ # do not call the real DESTROY since we store ourselves in $RA
}
sub get_log {
my $full_url = $self->{url};
my $old_url = $full_url;
$full_url .= "/$path" if length $path;
- SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
- $self->{url} = $full_url;
-
- my $reporter = $self->do_switch($rev_b, '',
- $recurse, $url_b, $editor, $pool);
+ my ($ra, $reparented);
+ if ($old_url ne $full_url) {
+ if ($old_url !~ m#^svn(\+ssh)?://#) {
+ SVN::_Ra::svn_ra_reparent($self->{session}, $full_url,
+ $pool);
+ $self->{url} = $full_url;
+ $reparented = 1;
+ } else {
+ $ra = Git::SVN::Ra->new($full_url);
+ }
+ }
+ $ra ||= $self;
+ my $reporter = $ra->do_switch($rev_b, '',
+ $recurse, $url_b, $editor, $pool);
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
$reporter->set_path('', $rev_a, 0, @lock, $pool);
$reporter->finish_report($pool);
- SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
- $self->{url} = $old_url;
+ if ($reparented) {
+ SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
+ $self->{url} = $old_url;
+ }
$pool->clear;
$editor->{git_commit_ok};