git-svn: canonicalize newly-minted URLs
Go through all the spots that use the new add_path_to_url() to make a new URL and canonicalize them. * copyfrom_path has to be canonicalized else find_parent_branch will get confused * due to the `canonicalize_url($full_url) ne $full_url)` line of logic in gs_do_switch(), $full_url is left alone until after. At this point SVN 1.7 passes except for 3 tests in t9100-git-svn-basic.sh that look like an SVN bug to do with symlinks. [ew: commit title] Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 28, 2012 at 02:47 UTC
705b49cb81351020b57f9356487e9b3fdeea1e40
2 files changed
+22
-6
perl/Git/SVN.pm
+14
-5
@@ -362,6 +362,8 @@ sub init_remote_config {
362
sub find_by_url { # repos_root and, path are optional
363
my ($class, $full_url, $repos_root, $path) = @_;
364
365
+ $full_url = canonicalize_url($full_url);
366
+
367
return undef unless defined $full_url;
368
remove_username($full_url);
369
remove_username($repos_root) if defined $repos_root;
@@ -400,6 +402,11 @@ sub find_by_url { # repos_root and, path are optional
402
}
403
$p =~ s#^\Q$z\E(?:/|$)#$prefix# or next;
404
}
405
+
406
+ # remote fetch paths are not URI escaped. Decode ours
407
+ # so they match
408
+ $p = uri_decode($p);
409
+
410
foreach my $f (keys %$fetch) {
411
next if $f ne $p;
412
return Git::SVN->new($fetch->{$f}, $repo_id, $f);
@@ -934,18 +941,18 @@ sub rewrite_uuid {
941
sub metadata_url {
942
my ($self) = @_;
943
my $url = $self->rewrite_root || $self->url;
937
- return add_path_to_url( $url, $self->path );
944
+ return canonicalize_url( add_path_to_url( $url, $self->path ) );
945
}
946
947
sub full_url {
948
my ($self) = @_;
942
- return add_path_to_url( $self->url, $self->path );
949
+ return canonicalize_url( add_path_to_url( $self->url, $self->path ) );
950
}
951
952
sub full_pushurl {
953
my ($self) = @_;
954
if ($self->{pushurl}) {
948
- return add_path_to_url( $self->{pushurl}, $self->path );
955
+ return canonicalize_url( add_path_to_url( $self->{pushurl}, $self->path ) );
956
} else {
957
return $self->full_url;
958
}
@@ -1113,7 +1120,7 @@ sub find_parent_branch {
1120
my $r = $i->{copyfrom_rev};
1121
my $repos_root = $self->ra->{repos_root};
1122
my $url = $self->ra->url;
1116
- my $new_url = add_path_to_url( $url, $branch_from );
1123
+ my $new_url = canonicalize_url( add_path_to_url( $url, $branch_from ) );
1124
print STDERR "Found possible branch point: ",
1125
"$new_url => ", $self->full_url, ", $r\n"
1126
unless $::_q > 1;
@@ -1869,7 +1876,9 @@ sub make_log_entry {
1876
$email ||= "$author\@$uuid";
1877
$commit_email ||= "$author\@$uuid";
1878
} elsif ($self->use_svnsync_props) {
1872
- my $full_url = add_path_to_url( $self->svnsync->{url}, $self->path );
1879
+ my $full_url = canonicalize_url(
1880
+ add_path_to_url( $self->svnsync->{url}, $self->path )
1881
+ );
1882
remove_username($full_url);
1883
my $uuid = $self->svnsync->{uuid};
1884
$log_entry{metadata} = "$full_url\@$rev $uuid";
perl/Git/SVN/Ra.pm
+8
-1
@@ -5,6 +5,7 @@ use warnings;
5
use SVN::Client;
6
use Git::SVN::Utils qw(
7
canonicalize_url
8
+ canonicalize_path
9
add_path_to_url
10
);
11
@@ -102,6 +103,7 @@ sub new {
103
$Git::SVN::Prompt::_no_auth_cache = 1;
104
}
105
} # no warnings 'once'
106
+
107
my $self = SVN::Ra->new(url => $url, auth => $baton,
108
config => $config,
109
pool => SVN::Pool->new,
@@ -198,6 +200,7 @@ sub get_log {
200
qw/copyfrom_path copyfrom_rev action/;
201
if ($s{'copyfrom_path'}) {
202
$s{'copyfrom_path'} =~ s/$prefix_regex//;
203
+ $s{'copyfrom_path'} = canonicalize_path($s{'copyfrom_path'});
204
}
205
$_[0]{$p} = \%s;
206
}
@@ -301,7 +304,11 @@ sub gs_do_switch {
304
$ra = Git::SVN::Ra->new($full_url);
305
$ra_invalid = 1;
306
} elsif ($old_url ne $full_url) {
304
- SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
307
+ SVN::_Ra::svn_ra_reparent(
308
+ $self->{session},
309
+ canonicalize_url($full_url),
310
+ $pool
311
+ );
312
$self->url($full_url);
313
$reparented = 1;
314
}