Git::SVN: use accessor for URLs internally
So later it can do automatic canonicalization. A later patch will make other things use the accessor. No functional change here. [ew: commit title] Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 27, 2012 at 13:00 UTC
06ee19e8e5401e90d3b8e60bcee4b25e7b49efc5
1 file changed
+28
-14
perl/Git/SVN.pm
+28
-14
@@ -351,7 +351,7 @@ sub init_remote_config {
351
"svn-remote.$self->{repo_id}.fetch",
352
$self->path.":".$self->refname);
353
}
354
- $self->{url} = $url;
354
+ $self->url($url);
355
}
356
357
sub find_by_url { # repos_root and, path are optional
@@ -453,9 +453,10 @@ sub new {
453
$path =~ s{/\z}{};
454
$self->path($path);
455
}
456
- $self->{url} = command_oneline('config', '--get',
457
- "svn-remote.$repo_id.url") or
456
+ my $url = command_oneline('config', '--get',
457
+ "svn-remote.$repo_id.url") or
458
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
459
+ $self->url($url);
460
$self->{pushurl} = eval { command_oneline('config', '--get',
461
"svn-remote.$repo_id.pushurl") };
462
$self->rebuild;
@@ -577,17 +578,18 @@ sub _set_svm_vars {
578
my $path = $self->path;
579
my %tried;
580
while (length $path) {
580
- unless ($tried{"$self->{url}/$path"}) {
581
+ my $try = $self->url . "/$path";
582
+ unless ($tried{$try}) {
583
return $ra if $self->read_svm_props($ra, $path, $r);
582
- $tried{"$self->{url}/$path"} = 1;
584
+ $tried{$try} = 1;
585
}
586
$path =~ s#/?[^/]+$##;
587
}
588
die "Path: '$path' should be ''\n" if $path ne '';
589
return $ra if $self->read_svm_props($ra, $path, $r);
588
- $tried{"$self->{url}/$path"} = 1;
590
+ $tried{$self->url."/$path"} = 1;
591
590
- if ($ra->{repos_root} eq $self->{url}) {
592
+ if ($ra->{repos_root} eq $self->url) {
593
die @err, (map { " $_\n" } keys %tried), "\n";
594
}
595
@@ -610,7 +612,7 @@ sub _set_svm_vars {
612
if (!$ok) {
613
die @err, (map { " $_\n" } keys %tried), "\n";
614
}
613
- Git::SVN::Ra->new($self->{url});
615
+ Git::SVN::Ra->new($self->url);
616
}
617
618
sub svnsync {
@@ -677,7 +679,7 @@ sub ra_uuid {
679
if (!$@ && $uuid && $uuid =~ /^([a-f\d\-]{30,})$/i) {
680
$self->{ra_uuid} = $uuid;
681
} else {
680
- die "ra_uuid called without URL\n" unless $self->{url};
682
+ die "ra_uuid called without URL\n" unless $self->url;
683
$self->{ra_uuid} = $self->ra->get_uuid;
684
tmp_config('--add', $key, $self->{ra_uuid});
685
}
@@ -701,7 +703,7 @@ sub repos_root {
703
704
sub ra {
705
my ($self) = shift;
704
- my $ra = Git::SVN::Ra->new($self->{url});
706
+ my $ra = Git::SVN::Ra->new($self->url);
707
$self->_set_repos_root($ra->{repos_root});
708
if ($self->use_svm_props && !$self->{svm}) {
709
if ($self->no_metadata) {
@@ -926,13 +928,13 @@ sub rewrite_uuid {
928
929
sub metadata_url {
930
my ($self) = @_;
929
- ($self->rewrite_root || $self->{url}) .
931
+ ($self->rewrite_root || $self->url) .
932
(length $self->path ? '/' . $self->path : '');
933
}
934
935
sub full_url {
936
my ($self) = @_;
935
- $self->{url} . (length $self->path ? '/' . $self->path : '');
937
+ $self->url . (length $self->path ? '/' . $self->path : '');
938
}
939
940
sub full_pushurl {
@@ -1436,7 +1438,7 @@ sub find_extra_svk_parents {
1438
for my $ticket ( @tickets ) {
1439
my ($uuid, $path, $rev) = split /:/, $ticket;
1440
if ( $uuid eq $self->ra_uuid ) {
1439
- my $url = $self->{url};
1441
+ my $url = $self->url;
1442
my $repos_root = $url;
1443
my $branch_from = $path;
1444
$branch_from =~ s{^/}{};
@@ -1682,7 +1684,7 @@ sub find_extra_svn_parents {
1684
# are now marked as merge, we can add the tip as a parent.
1685
my @merges = split "\n", $mergeinfo;
1686
my @merge_tips;
1685
- my $url = $self->{url};
1687
+ my $url = $self->url;
1688
my $uuid = $self->ra_uuid;
1689
my %ranges;
1690
for my $merge ( @merges ) {
@@ -2306,6 +2308,18 @@ sub path {
2308
return $self->{path};
2309
}
2310
2311
+sub url {
2312
+ my $self = shift;
2313
+
2314
+ if (@_) {
2315
+ my $url = shift;
2316
+ $self->{url} = $url;
2317
+ return;
2318
+ }
2319
+
2320
+ return $self->{url};
2321
+}
2322
+
2323
# for read-only access of old .rev_db formats
2324
sub unlink_rev_db_symlink {
2325
my ($self) = @_;