Git::SVN::Ra: use accessor for URLs
Later it can canonicalize automatically. A later change will make other things use the accessor. No functional change. [ew: commit title, reformatted accessor to match existing style] Signed-off-by: Eric Wong <normalperson@yhbt.net>
Michael G. Schwern committed
Jul 27, 2012 at 13:00 UTC
b4943dc96324fec568125d7a5af1c4fdbd078543
1 file changed
+27
-11
perl/Git/SVN/Ra.pm
+27
-11
@@ -84,7 +84,7 @@ sub escape_url {
84
sub new {
85
my ($class, $url) = @_;
86
$url =~ s!/+$!!;
87
- return $RA if ($RA && $RA->{url} eq $url);
87
+ return $RA if ($RA && $RA->url eq $url);
88
89
::_req_svn();
90
@@ -119,13 +119,29 @@ sub new {
119
config => $config,
120
pool => SVN::Pool->new,
121
auth_provider_callbacks => $callbacks);
122
- $self->{url} = $url;
122
+ $RA = bless $self, $class;
123
+
124
+ # Make sure its canonicalized
125
+ $self->url($url);
126
$self->{svn_path} = $url;
127
$self->{repos_root} = $self->get_repos_root;
128
$self->{svn_path} =~ s#^\Q$self->{repos_root}\E(/|$)##;
129
$self->{cache} = { check_path => { r => 0, data => {} },
130
get_dir => { r => 0, data => {} } };
128
- $RA = bless $self, $class;
131
+
132
+ return $RA;
133
+}
134
+
135
+sub url {
136
+ my $self = shift;
137
+
138
+ if (@_) {
139
+ my $url = shift;
140
+ $self->{url} = $url;
141
+ return;
142
+ }
143
+
144
+ return $self->{url};
145
}
146
147
sub check_path {
@@ -285,7 +301,7 @@ sub gs_do_switch {
301
my $path = $gs->{path};
302
my $pool = SVN::Pool->new;
303
288
- my $full_url = $self->{url};
304
+ my $full_url = $self->url;
305
my $old_url = $full_url;
306
$full_url .= '/' . $path if length $path;
307
my ($ra, $reparented);
@@ -300,7 +316,7 @@ sub gs_do_switch {
316
$ra_invalid = 1;
317
} elsif ($old_url ne $full_url) {
318
SVN::_Ra::svn_ra_reparent($self->{session}, $full_url, $pool);
303
- $self->{url} = $full_url;
319
+ $self->url($full_url);
320
$reparented = 1;
321
}
322
@@ -313,7 +329,7 @@ sub gs_do_switch {
329
330
if ($reparented) {
331
SVN::_Ra::svn_ra_reparent($self->{session}, $old_url, $pool);
316
- $self->{url} = $old_url;
332
+ $self->url($old_url);
333
}
334
335
$pool->clear;
@@ -362,7 +378,7 @@ sub gs_fetch_loop_common {
378
my $inc = $_log_window_size;
379
my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc);
380
my $longest_path = longest_common_path($gsv, $globs);
365
- my $ra_url = $self->{url};
381
+ my $ra_url = $self->url;
382
my $find_trailing_edge;
383
while (1) {
384
my %revs;
@@ -508,7 +524,7 @@ sub match_globs {
524
($self->check_path($p, $r) !=
525
$SVN::Node::dir));
526
next unless $p =~ /$g->{path}->{regex}/;
511
- $exists->{$p} = Git::SVN->init($self->{url}, $p, undef,
527
+ $exists->{$p} = Git::SVN->init($self->url, $p, undef,
528
$g->{ref}->full_path($de), 1);
529
}
530
}
@@ -532,7 +548,7 @@ sub match_globs {
548
next if ($self->check_path($pathname, $r) !=
549
$SVN::Node::dir);
550
$exists->{$pathname} = Git::SVN->init(
535
- $self->{url}, $pathname, undef,
551
+ $self->url, $pathname, undef,
552
$g->{ref}->full_path($p), 1);
553
}
554
my $c = '';
@@ -548,7 +564,7 @@ sub match_globs {
564
565
sub minimize_url {
566
my ($self) = @_;
551
- return $self->{url} if ($self->{url} eq $self->{repos_root});
567
+ return $self->url if ($self->url eq $self->{repos_root});
568
my $url = $self->{repos_root};
569
my @components = split(m!/!, $self->{svn_path});
570
my $c = '';
@@ -568,7 +584,7 @@ sub can_do_switch {
584
unless (defined $can_do_switch) {
585
my $pool = SVN::Pool->new;
586
my $rep = eval {
571
- $self->do_switch(1, '', 0, $self->{url},
587
+ $self->do_switch(1, '', 0, $self->url,
588
SVN::Delta::Editor->new, $pool);
589
};
590
if ($@) {