git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-svn: re-map repository URLs and UUIDs on SVK mirror paths

From
Sam Vilain <sam@vilain.net>
Date
Feb 10, 2007, 23:34 UTC
Message-ID
<20070210233750.A333013A384@magnus.utsl.gen.nz>
If an SVN revision has a property, "svm:headrev", it is likely that
the revision was created by SVN::Mirror (a part of SVK).  The property
contains a repository UUID and a revision.  We want to make it look
like we are mirroring the original URL, so introduce a helper function
that returns the original identity URL and UUID, and use it when
generating commit messages.
---
 git-svn.perl |   39 +++++++++++++++++++++++++++++++++------
 1 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 59d9faf..5b0d8b7 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1055,10 +1055,23 @@ sub do_git_commit {
 	defined(my $pid = open3(my $msg_fh, my $out_fh, '>&STDERR', @exec))
 	                                                           or croak $!;
 	print $msg_fh $log_entry->{log} or croak $!;
+	my $at = "";
 	unless ($_no_metadata) {
-		print $msg_fh "\ngit-svn-id: ", $self->full_url, '@',
-		              $log_entry->{revision}, ' ',
-		              $self->ra->uuid, "\n" or croak $!;
+		my $full_url = $self->full_url;
+		my $revision = $log_entry->{revision};
+		my $uuid = $self->ra->uuid;
+		my $repo_id = $Git::SVN::default_repo_id;
+		$DB::single = 1;
+		if ( $log_entry->{headrev} ) {
+			my ($from_uuid, $rev) = $log_entry->{headrev} =~ m{^([a-f0-9\-]{30,}):(\d+)$};
+			($full_url, $uuid) = get_svm_url( $repo_id, $full_url, $uuid );
+			die "UUID mismatch on SVM path : $uuid vs $from_uuid"
+				if $from_uuid ne $uuid;
+			$revision = $rev;
+			$at = " (\@$rev)";
+		}
+		print $msg_fh "\ngit-svn-id: ", $full_url, '@',
+		              $revision, ' ', $uuid, "\n" or croak $!;
 	}
 	$msg_fh->flush == 0 or croak $!;
 	close $msg_fh or croak $!;
@@ -1074,7 +1087,7 @@ sub do_git_commit {
 
 	$self->{last_rev} = $log_entry->{revision};
 	$self->{last_commit} = $commit;
-	print "r$log_entry->{revision} = $commit ($self->{ref_id})\n";
+	print "r$log_entry->{revision}$at = $commit ($self->{ref_id})\n";
 	if (defined $_repack && (--$_repack_nr == 0)) {
 		$_repack_nr = $_repack;
 		# repack doesn't use any arguments with spaces in them, does it?
@@ -1284,8 +1297,9 @@ sub make_log_entry {
 	my $rp = $self->ra->rev_proplist($rev);
 	foreach (sort keys %$rp) {
 		my $v = $rp->{$_};
-		if (/^svn:(author|date|log)$/) {
-			$log_entry{$1} = $v;
+		$DB::single = 1 if /svm:/;
+		if (/^(?:svn:(author|date|log)|svm:(headrev))$/) {
+			$log_entry{$1||$2} = $v;
 		} else {
 			print $un "  rev_prop: ", uri_encode($_), ' ',
 		                  uri_encode($v), "\n";
@@ -1492,6 +1506,19 @@ sub uri_encode {
 	$f
 }
 
+our %svm_urls;
+sub get_svm_url {
+	my ($repo_id, $url, $uuid) = @_;
+	my $spec = $url.":".$uuid;
+	if (!exists $svm_urls{$spec}) {
+		my $source = `git-repo-config --get svn-remote.$repo_id.source`;
+		my $svmuuid = `git-repo-config --get svn-remote.$repo_id.uuid`;
+		chomp for ($source, $svmuuid);
+		$svm_urls{$spec}=[$source,$svmuuid];
+	}
+	($url,$uuid) = @{$svm_urls{$spec}};
+}
+
 package Git::SVN::Prompt;
 use strict;
 use warnings;
-- 
1.5.0.rc3.g3e023
Next: Eric Wong
Message 1 of 5 in “git-svn: re-map repository URLs and UUIDs on SVK mirror paths”
  1. git-svn: re-map repository URLs and UUIDs on SVK mirror pathsSam Vilain, Feb 10, 2007
  2. Eric WongFeb 11, 2007
  3. Eric WongFeb 11, 2007
  4. Eric WongFeb 13, 2007
  5. Sam VilainFeb 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.