git-svn: don't rely on do_switch + reparenting with svn(+ssh)://
I can't seem to figure out what I or the SVN libraries are doing wrong, but it appears to be related to reparent and probably some global structure that gets reset if multiple SVN connections are being used. So now, in order to use do_switch; we'll open a new connection to the repository with the complete URL; but we can't seem to ever use an existing Ra object after another one has been created... Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jan 29, 2007 at 19:16 UTC
5d3b7cd5fe5d0410915cc68b641415901e1b113e
1 file changed
+27
-15
git-svn.perl
+27
-15
@@ -870,7 +870,7 @@ sub refname { "refs/remotes/$_[0]->{ref_id}" }
870
871
sub ra {
872
my ($self) = shift;
873
- $self->{ra} ||= Git::SVN::Ra->new($self->{url});
873
+ Git::SVN::Ra->new($self->{url});
874
}
875
876
sub rel_path {
@@ -897,9 +897,10 @@ sub copy_remote_ref {
897
sub traverse_ignore {
898
my ($self, $fh, $path, $r) = @_;
899
$path =~ s#^/+##g;
900
- my ($dirent, undef, $props) = $self->ra->get_dir($path, $r);
900
+ my $ra = $self->ra;
901
+ my ($dirent, undef, $props) = $ra->get_dir($path, $r);
902
my $p = $path;
902
- $p =~ s#^\Q$self->{ra}->{svn_path}\E/##;
903
+ $p =~ s#^\Q$ra->{svn_path}\E/##;
904
print $fh length $p ? "\n# $p\n" : "\n# /\n";
905
if (my $s = $props->{'svn:ignore'}) {
906
$s =~ s/[\r\n]+/\n/g;
@@ -1027,7 +1028,7 @@ sub get_commit_parents {
1028
1029
sub full_url {
1030
my ($self) = @_;
1030
- $self->ra->{url} . (length $self->{path} ? '/' . $self->{path} : '');
1031
+ $self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
1032
}
1033
1034
sub do_git_commit {
@@ -2165,7 +2166,7 @@ use vars qw/@ISA $config_dir/;
2166
use strict;
2167
use warnings;
2168
my ($can_do_switch);
2168
-my %RA;
2169
+my $RA;
2170
2171
BEGIN {
2172
# enforce temporary pool usage for some simple functions
@@ -2185,7 +2186,7 @@ BEGIN {
2186
sub new {
2187
my ($class, $url) = @_;
2188
$url =~ s!/+$!!;
2188
- return $RA{$url} if $RA{$url};
2189
+ return $RA if ($RA && $RA->{url} eq $url);
2190
2191
SVN::_Core::svn_config_ensure($config_dir, undef);
2192
my ($baton, $callbacks) = SVN::Core::auth_open_helper([
@@ -2211,11 +2212,11 @@ sub new {
2212
$self->{svn_path} = $url;
2213
$self->{repos_root} = $self->get_repos_root;
2214
$self->{svn_path} =~ s#^\Q$self->{repos_root}\E/*##;
2214
- $RA{$url} = bless $self, $class;
2215
+ $RA = bless $self, $class;
2216
}
2217
2218
sub DESTROY {
2218
- # do not call the real DESTROY since we store ourselves in %RA
2219
+ # do not call the real DESTROY since we store ourselves in $RA
2220
}
2221
2222
sub get_log {
@@ -2276,17 +2277,28 @@ sub gs_do_switch {
2277
my $full_url = $self->{url};
2278
my $old_url = $full_url;
2279
$full_url .= "/$path" if length $path;
2279
- SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
2280
- $self->{url} = $full_url;
2281
-
2282
- my $reporter = $self->do_switch($rev_b, '',
2283
- $recurse, $url_b, $editor, $pool);
2280
+ my ($ra, $reparented);
2281
+ if ($old_url ne $full_url) {
2282
+ if ($old_url !~ m#^svn(\+ssh)?://#) {
2283
+ SVN::_Ra::svn_ra_reparent($self->{session}, $full_url,
2284
+ $pool);
2285
+ $self->{url} = $full_url;
2286
+ $reparented = 1;
2287
+ } else {
2288
+ $ra = Git::SVN::Ra->new($full_url);
2289
+ }
2290
+ }
2291
+ $ra ||= $self;
2292
+ my $reporter = $ra->do_switch($rev_b, '',
2293
+ $recurse, $url_b, $editor, $pool);
2294
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : ();
2295
$reporter->set_path('', $rev_a, 0, @lock, $pool);
2296
$reporter->finish_report($pool);
2297
2288
- SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
2289
- $self->{url} = $old_url;
2298
+ if ($reparented) {
2299
+ SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
2300
+ $self->{url} = $old_url;
2301
+ }
2302
2303
$pool->clear;
2304
$editor->{git_commit_ok};