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

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

From
Sam Vilain <sam@vilain.net>
Date
Dec 4, 2006, 09:43 UTC
Message-ID
<20061204235724.72628139B0E@magnus.utsl.gen.nz>
If an SVN revision has a property, "svm:headrev", it is likely that
the revision was created by "svk sync".  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 trio, and use it when generating commit
messages and dummy e-mail domains.
---
 git-svn.perl |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 74b04d0..1f72f0d 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2076,8 +2076,9 @@ sub git_commit {
 								or croak $!;
 	print $msg_fh $log_msg->{msg} or croak $!;
 	unless ($_no_metadata) {
-		print $msg_fh "\ngit-svn-id: $SVN_URL\@$log_msg->{revision}",
-					" $SVN_UUID\n" or croak $!;
+	    my ($url, $uuid, $rev) = svn_commit_id($log_msg);
+	    print $msg_fh "\ngit-svn-id: $url\@$rev $uuid\n"
+		or croak $!;
 	}
 	$msg_fh->flush == 0 or croak $!;
 	close $msg_fh or croak $!;
@@ -2109,14 +2110,36 @@ sub get_svm_url {
     chomp($SVM_UUID = `git-repo-config --get svn.svkuuid`);
 }
 
+sub svn_commit_id {
+    my $log_msg = shift;
+    my ($url, $uuid, $rev) = ($SVN_URL, $SVN_UUID, $log_msg->{revision});
+    my $svm_headrev = $log_msg->{revprops}{'svm:headrev'};
+    if ( $svm_headrev ) {
+	my ( $_uuid, $_rev) = split /:/, $svm_headrev;
+	chomp($_rev);
+	if ( !$SVM_URL ) {
+	    get_svm_url();
+	}
+	if ( $_uuid ne $SVM_UUID ) {
+	    warn "$uuid:$rev claims to be $_uuid:$_rev, but that's unknown";
+	} else {
+	    ($url, $uuid, $rev) = ($SVM_URL, $SVM_UUID, $_rev);
+	}
+    }
+    ($url, $uuid, $rev);
+}
+
 sub set_commit_env {
 	my ($log_msg) = @_;
 	my $author = $log_msg->{author};
 	if (!defined $author || length $author == 0) {
 		$author = '(no author)';
 	}
-	my ($name,$email) = defined $users{$author} ?  @{$users{$author}}
-				: ($author,"$author\@$SVN_UUID");
+	my ($name,$email) = defined $users{$author} ? @{$users{$author}}
+	    : do {
+		my (undef, $uuid, undef) = svn_commit_id($log_msg);
+		($author,"$author\@$uuid")
+	    };
 	$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;
 	$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;
 	$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};
-- 
1.4.4.1.ge918e-dirty
Message 1 of 1 in “git-svn: re-map repository URLs and UUIDs on SVK mirror paths”
  1. 4/4 git-svn: re-map repository URLs and UUIDs on SVK mirror pathsSam Vilain, Dec 4, 2006

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.