@matheusbsbs / matheus-bagliano / commits / 6173c197c9
Fork 0

git-svn: avoid fetching files twice in the same revision

SVN is not entirely consistent in returning log information and sometimes returns file information when adding subdirectories, and sometimes it does not (only returning information about the directory that was added). This caused git-svn to occasionally add a file to the list of files to be fetched twice. Now we change the data structure to be hash to avoid repeated fetches. As of now (in master), this only affects repositories fetched without deltas enabled (file://, and when manually overriden with GIT_SVN_DELTA_FETCH=0); so this bug mainly affects users of 1.4.4.1 and maint. Thanks to Florian Weimer for reporting this bug. [jc: backported for maint] Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Dec 2, 2006 at 16:19 UTC 6173c197c9a23fa8594f18fd2c856407d4af31c1
1 file changed +5 -5
git-svn.perl
+5 -5
@@ -2778,7 +2778,7 @@ sub process_rm {
2778 sub libsvn_fetch {
2779 my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
2780 open my $gui, '| git-update-index -z --index-info' or croak $!;
2781 - my @amr;
2781 + my %amr;
2782 foreach my $f (keys %$paths) {
2783 my $m = $paths->{$f}->action();
2784 $f =~ s#^/+##;
@@ -2792,7 +2792,7 @@ sub libsvn_fetch {
2792 my $t = $SVN->check_path($f, $rev, $pool);
2793 if ($t == $SVN::Node::file) {
2794 if ($m =~ /^[AMR]$/) {
2795 - push @amr, [ $m, $f ];
2795 + $amr{$f} = $m;
2796 } else {
2797 die "Unrecognized action: $m, ($f r$rev)\n";
2798 }
@@ -2800,13 +2800,13 @@ sub libsvn_fetch {
2800 my @traversed = ();
2801 libsvn_traverse($gui, '', $f, $rev, \@traversed);
2802 foreach (@traversed) {
2803 - push @amr, [ $m, $_ ]
2803 + $amr{$_} = $m;
2804 }
2805 }
2806 $pool->clear;
2807 }
2808 - foreach (@amr) {
2809 - libsvn_get_file($gui, $_->[1], $rev, $_->[0]);
2808 + foreach (keys %amr) {
2809 + libsvn_get_file($gui, $_, $rev, $amr{$_});
2810 }
2811 close $gui or croak $?;
2812 return libsvn_log_entry($rev, $author, $date, $msg, [$last_commit]);