All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-svn: detect SVN::Mirror breadcrumbs on multi-init
@ 2007-02-10 23:15 Sam Vilain
  0 siblings, 0 replies; only message in thread
From: Sam Vilain @ 2007-02-10 23:15 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

SVN::Mirror leaves a little directory property on the root of its
mirrored paths to say the URL and repository UUID of the path that
this path mirrors.  If we see them, save them in the config for later
use.
---
 git-svn.perl |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 0c36e8b..59d9faf 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -358,8 +358,34 @@ sub cmd_multi_init {
 						   undef, $trunk_ref);
 		}
 	}
+	my $ra;
+	if ($url) {
+		$ra = Git::SVN::Ra->new($url);
+		my $r = $ra->get_latest_revnum;
+		my (undef, undef, $props) = $ra->get_dir('', $r);
+		if ( my $src = $props->{'svm:source'} ) {
+			# don't know wtf a ! is there for, also the
+			# username is of no interest
+			$src =~ s{!$}{};
+			$src =~ s{(^[a-z\+]*://)[^/@]*@}{$1};
+
+			# XXX - is this right?
+			my $remote_id = $Git::SVN::default_repo_id;
+			my $section = "svn-remote.$remote_id";
+
+			print STDERR "SVN::Mirror breadcrumbs detected:\n",
+			    "    $src => $url\n";
+
+			# store the source as a repo-config item
+			command_noisy('config', "$section.source", $src);
+
+			my $uuid = $props->{'svm:uuid'};
+			$uuid =~ m{^[0-9a-f\-]{30,}$}
+			    or croak "doesn't look right - svm:uuid is '$uuid'";
+			command_noisy('config', "$section.uuid", $uuid);
+		}
+	}
 	return unless defined $_branches || defined $_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/');
 }
-- 
1.5.0.rc3.g3e023

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-10 23:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-10 23:15 [PATCH] git-svn: detect SVN::Mirror breadcrumbs on multi-init Sam Vilain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.