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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]