@matheusbsbs / matheus-bagliano / commits / 1ca72aef45
Fork 0

contrib/git-svn: avoid re-reading the repository uuid, it never changes

If it does change, we're screwed anyways as SVN will refuse to commit or update. We also never access more than one SVN repository per-invocation, so we can store it as a global, too. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Mar 3, 2006 at 01:20 UTC 1ca72aef45191016e2108855607c9e03b8c93528
1 file changed +12 -15
contrib/git-svn/git-svn.perl
+12 -15
@@ -4,7 +4,7 @@
4 use warnings;
5 use strict;
6 use vars qw/ $AUTHOR $VERSION
7 - $SVN_URL $SVN_INFO $SVN_WC
7 + $SVN_URL $SVN_INFO $SVN_WC $SVN_UUID
8 $GIT_SVN_INDEX $GIT_SVN
9 $GIT_DIR $REV_DIR/;
10 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
@@ -114,7 +114,6 @@ sub version {
114
115 sub rebuild {
116 $SVN_URL = shift or undef;
117 - my $repo_uuid;
117 my $newest_rev = 0;
118 if ($_upgrade) {
119 sys('git-update-ref',"refs/remotes/$GIT_SVN","$GIT_SVN-HEAD");
@@ -150,7 +149,7 @@ sub rebuild {
149
150 # if we merged or otherwise started elsewhere, this is
151 # how we break out of it
153 - next if (defined $repo_uuid && ($uuid ne $repo_uuid));
152 + next if (defined $SVN_UUID && ($uuid ne $SVN_UUID));
153 next if (defined $SVN_URL && ($url ne $SVN_URL));
154
155 print "r$rev = $c\n";
@@ -159,7 +158,7 @@ sub rebuild {
158 croak "SVN repository location required: $url\n";
159 }
160 $SVN_URL ||= $url;
162 - $repo_uuid ||= setup_git_svn();
161 + $SVN_UUID ||= setup_git_svn();
162 $latest = $rev;
163 }
164 assert_revision_eq_or_unknown($rev, $c);
@@ -252,7 +251,7 @@ sub commit {
251 print "Reading from stdin...\n";
252 @commits = ();
253 while (<STDIN>) {
255 - if (/\b($sha1_short)\b/) {
254 + if (/\b($sha1_short)\b/o) {
255 unshift @commits, $1;
256 }
257 }
@@ -320,14 +319,14 @@ sub setup_git_svn {
319 mkpath(["$GIT_DIR/$GIT_SVN/info"]);
320 mkpath([$REV_DIR]);
321 s_to_file($SVN_URL,"$GIT_DIR/$GIT_SVN/info/url");
323 - my $uuid = svn_info($SVN_URL)->{'Repository UUID'} or
322 + $SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or
323 croak "Repository UUID unreadable\n";
325 - s_to_file($uuid,"$GIT_DIR/$GIT_SVN/info/uuid");
324 + s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
325
326 open my $fd, '>>', "$GIT_DIR/$GIT_SVN/info/exclude" or croak $!;
327 print $fd '.svn',"\n";
328 close $fd or croak $!;
330 - return $uuid;
329 + return $SVN_UUID;
330 }
331
332 sub assert_svn_wc_clean {
@@ -850,9 +849,7 @@ sub git_commit {
849 my ($log_msg, @parents) = @_;
850 assert_revision_unknown($log_msg->{revision});
851 my $out_fh = IO::File->new_tmpfile or croak $!;
853 - my $info = svn_info('.');
854 - my $uuid = $info->{'Repository UUID'};
855 - defined $uuid or croak "Unable to get Repository UUID\n";
852 + $SVN_UUID ||= svn_info('.')->{'Repository UUID'};
853
854 map_tree_joins() if (@_branch_from && !%tree_map);
855
@@ -891,11 +888,11 @@ sub git_commit {
888 my $msg_fh = IO::File->new_tmpfile or croak $!;
889 print $msg_fh $log_msg->{msg}, "\ngit-svn-id: ",
890 "$SVN_URL\@$log_msg->{revision}",
894 - " $uuid\n" or croak $!;
891 + " $SVN_UUID\n" or croak $!;
892 $msg_fh->flush == 0 or croak $!;
893 seek $msg_fh, 0, 0 or croak $!;
894
898 - set_commit_env($log_msg, $uuid);
895 + set_commit_env($log_msg);
896
897 my @exec = ('git-commit-tree',$tree);
898 push @exec, '-p', $_ foreach @exec_parents;
@@ -923,10 +920,10 @@ sub git_commit {
920 }
921
922 sub set_commit_env {
926 - my ($log_msg, $uuid) = @_;
923 + my ($log_msg) = @_;
924 my $author = $log_msg->{author};
925 my ($name,$email) = defined $users{$author} ? @{$users{$author}}
929 - : ($author,"$author\@$uuid");
926 + : ($author,"$author\@$SVN_UUID");
927 $ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;
928 $ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;
929 $ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};