diff options
author | Eric Wong <normalperson@yhbt.net> | 2007-01-11 17:09:26 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2007-02-23 00:57:08 -0800 |
commit | e7db67e6f18495332c4d688d3291b05851526a6e (patch) | |
tree | b0028cba2071bf23ca830c8efa30f64d049f6f79 /git-svn.perl | |
parent | git-svn: convert multi-init over to using Git::SVN (diff) | |
download | tgif-e7db67e6f18495332c4d688d3291b05851526a6e.tar.xz |
git-svn: make multi-init capable of reusing the Ra connection
If a user specified a seperate URL and --tags/--branches as
a sepearte URL, allow the Ra object (and therefore the connection)
to be reused.
We'll get rid of libsvn_ls_fullurl() since it was only used
in one place.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-x | git-svn.perl | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/git-svn.perl b/git-svn.perl index 72f73ea623..02786f1a6a 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -595,8 +595,9 @@ sub cmd_multi_init { command_noisy('config', 'svn.trunk', $trunk_url); } } - complete_url_ls_init($url, $_branches, '--branches/-b', $_prefix); - complete_url_ls_init($url, $_tags, '--tags/-t', $_prefix . 'tags/'); + my $ra = $url ? Git::SVN::Ra->new($url) : undef; + complete_url_ls_init($ra, $_branches, '--branches/-b', $_prefix); + complete_url_ls_init($ra, $_tags, '--tags/-t', $_prefix . 'tags/'); } sub multi_fetch { @@ -890,29 +891,38 @@ sub complete_svn_url { } sub complete_url_ls_init { - my ($url, $path, $switch, $pfx) = @_; + my ($ra, $path, $switch, $pfx) = @_; unless ($path) { print STDERR "W: $switch not specified\n"; return; } - my $full_url = complete_svn_url($url, $path); - my @ls = libsvn_ls_fullurl($full_url); - foreach my $u (map { "$full_url/$_" } (grep m!/$!, @ls)) { - $u =~ s#/+$##; - if ($u !~ m!\Q$full_url\E/(.+)$!) { - print STDERR "W: Unrecognized URL: $u\n"; - die "This should never happen\n"; + $path =~ s#/+$##; + if ($path =~ m#^[a-z\+]+://#) { + $ra = Git::SVN::Ra->new($path); + $path = ''; + } else { + $path =~ s#^/+##; + unless ($ra) { + fatal("E: '$path' is not a complete URL ", + "and a separate URL is not specified\n"); } - # don't try to init already existing refs - my $id = $pfx.$1; + } + my $r = defined $_revision ? $_revision : $ra->get_latest_revnum; + my ($dirent, undef, undef) = $ra->get_dir($path, $r); + my $url = $ra->{url} . (length $path ? "/$path" : ''); + foreach my $d (sort keys %$dirent) { + next if ($dirent->{$d}->kind != $SVN::Node::dir); + my $u = "$url/$d"; + my $id = "$pfx$d"; my $gs = eval { Git::SVN->new($id) }; + # don't try to init already existing refs unless ($gs) { print "init $u => $id\n"; Git::SVN->init($id, $u); } } my ($n) = ($switch =~ /^--(\w+)/); - command_noisy('config', "svn.$n", $full_url); + command_noisy('config', "svn.$n", $url); } sub common_prefix { @@ -2851,20 +2861,6 @@ sub libsvn_commit_cb { } } -sub libsvn_ls_fullurl { - my $fullurl = shift; - my $ra = Git::SVN::Ra->new($fullurl); - my @ret; - my $r = defined $_revision ? $_revision : $ra->get_latest_revnum; - my ($dirent, undef, undef) = $ra->get_dir('', $r); - foreach my $d (sort keys %$dirent) { - if ($dirent->{$d}->kind == $SVN::Node::dir) { - push @ret, "$d/"; # add '/' for compat with cli svn - } - } - return @ret; -} - sub libsvn_skip_unknown_revs { my $err = shift; my $errno = $err->apr_err(); |