{"thread":{"id":"43350","subject":"[PATCH 4/4] git-svn: re-map repository URLs and UUIDs on SVK mirror paths","startedAt":"2006-12-04T09:43:41Z","lastAt":"2006-12-04T09:43:41Z","messageCount":1,"participants":["Sam Vilain"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"294442","messageId":"20061204235724.72628139B0E@magnus.utsl.gen.nz","threadId":"43350","inReplyTo":null,"subject":"[PATCH 4/4] git-svn: re-map repository URLs and UUIDs on SVK mirror paths","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2006-12-04T09:43:41Z","receivedAt":"2006-12-04T09:43:41Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"If an SVN revision has a property, \"svm:headrev\", it is likely that\nthe revision was created by \"svk sync\".  The property contains a\nrepository UUID and a revision.  We want to make it look like we are\nmirroring the original URL, so introduce a helper function that\nreturns the original identity trio, and use it when generating commit\nmessages and dummy e-mail domains.\n---\n git-svn.perl |   31 +++++++++++++++++++++++++++----\n 1 files changed, 27 insertions(+), 4 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 74b04d0..1f72f0d 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -2076,8 +2076,9 @@ sub git_commit {\n \t\t\t\t\t\t\t\tor croak $!;\n \tprint $msg_fh $log_msg->{msg} or croak $!;\n \tunless ($_no_metadata) {\n-\t\tprint $msg_fh \"\\ngit-svn-id: $SVN_URL\\@$log_msg->{revision}\",\n-\t\t\t\t\t\" $SVN_UUID\\n\" or croak $!;\n+\t    my ($url, $uuid, $rev) = svn_commit_id($log_msg);\n+\t    print $msg_fh \"\\ngit-svn-id: $url\\@$rev $uuid\\n\"\n+\t\tor croak $!;\n \t}\n \t$msg_fh->flush == 0 or croak $!;\n \tclose $msg_fh or croak $!;\n@@ -2109,14 +2110,36 @@ sub get_svm_url {\n     chomp($SVM_UUID = `git-repo-config --get svn.svkuuid`);\n }\n \n+sub svn_commit_id {\n+    my $log_msg = shift;\n+    my ($url, $uuid, $rev) = ($SVN_URL, $SVN_UUID, $log_msg->{revision});\n+    my $svm_headrev = $log_msg->{revprops}{'svm:headrev'};\n+    if ( $svm_headrev ) {\n+\tmy ( $_uuid, $_rev) = split /:/, $svm_headrev;\n+\tchomp($_rev);\n+\tif ( !$SVM_URL ) {\n+\t    get_svm_url();\n+\t}\n+\tif ( $_uuid ne $SVM_UUID ) {\n+\t    warn \"$uuid:$rev claims to be $_uuid:$_rev, but that's unknown\";\n+\t} else {\n+\t    ($url, $uuid, $rev) = ($SVM_URL, $SVM_UUID, $_rev);\n+\t}\n+    }\n+    ($url, $uuid, $rev);\n+}\n+\n sub set_commit_env {\n \tmy ($log_msg) = @_;\n \tmy $author = $log_msg->{author};\n \tif (!defined $author || length $author == 0) {\n \t\t$author = '(no author)';\n \t}\n-\tmy ($name,$email) = defined $users{$author} ?  @{$users{$author}}\n-\t\t\t\t: ($author,\"$author\\@$SVN_UUID\");\n+\tmy ($name,$email) = defined $users{$author} ? @{$users{$author}}\n+\t    : do {\n+\t\tmy (undef, $uuid, undef) = svn_commit_id($log_msg);\n+\t\t($author,\"$author\\@$uuid\")\n+\t    };\n \t$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;\n \t$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;\n \t$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};\n-- \n1.4.4.1.ge918e-dirty\n"}]}