git-svn: improve repository URL matching when following parents
This way we can avoid the spawning of a new SVN::Ra session by reusing the existing one. The most problematic issue is that some svn servers disallow too many connections from a single IP, so this will allow git-svn to fetch from those repositories with a higher success rate by using fewer connections. This sometimes showed up as a new (and redundant) [svn-remote "$parent_refname"] entry in $GIT_DIR/svn/.metadata. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Jan 29, 2008 at 01:18 UTC
c586879cdfa4f8181a14e953a9152a4639eef333
1 file changed
+6
-1
git-svn.perl
+6
-1
@@ -2229,7 +2229,12 @@ sub find_parent_branch {
2229
# just grow a tail if we're not unique enough :x
2230
$ref_id .= '-' while find_ref($ref_id);
2231
print STDERR "Initializing parent: $ref_id\n";
2232
- $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
2232
+ my ($u, $p) = ($new_url, '');
2233
+ if ($u =~ s#^\Q$url\E(/|$)##) {
2234
+ $p = $u;
2235
+ $u = $url;
2236
+ }
2237
+ $gs = Git::SVN->init($u, $p, $self->{repo_id}, $ref_id, 1);
2238
}
2239
my ($r0, $parent) = $gs->find_rev_before($r, 1);
2240
if (!defined $r0 || !defined $parent) {