git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Vilain <sam@vilain.net>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org
Subject: [PATCH 5/5] git-svn: re-map repository URLs and UUIDs on SVK mirror paths
Date: Tue, 05 Dec 2006 16:17:38 +1100	[thread overview]
Message-ID: <20061205051738.16552.22494.stgit@localhost> (raw)
In-Reply-To: <20061205051738.16552.8987.stgit@localhost>

From: Sam Vilain <sam@vilain.net>

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 70c34b0..13a1f24 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};

  reply	other threads:[~2006-12-05  5:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-05  5:17 [PATCH 1/5] git-svn: make test for SVK mirror path import Sam Vilain
2006-12-05  5:17 ` Sam Vilain [this message]
2006-12-05  8:58   ` [PATCH 5/5] git-svn: re-map repository URLs and UUIDs on SVK mirror paths Eric Wong
2006-12-07  0:20     ` Sam Vilain
2006-12-07 20:02       ` Eric Wong
2006-12-08 10:20         ` [PATCH] git-svn: use do_switch for --follow-parent if the SVN library supports it Eric Wong
2006-12-05  5:17 ` [PATCH 4/5] git-svn: collect revision properties when fetching Sam Vilain
2006-12-05  5:17 ` [PATCH 3/5] git-svn: collect SVK source URL on mirror paths Sam Vilain
2006-12-05  5:17 ` [PATCH 2/5] git-svn: let libsvn_ls_fullurl return properties too Sam Vilain
2006-12-05  8:40 ` [PATCH 1/5] git-svn: make test for SVK mirror path import Eric Wong
2006-12-05 10:32 ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061205051738.16552.22494.stgit@localhost \
    --to=sam@vilain.net \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).