From: Junio C Hamano Date: Sun, 3 Dec 2006 01:26:58 +0000 (-0800) Subject: Merge branch 'maint' X-Git-Tag: v1.5.0-rc0~173 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=278fcd7debf19c1efee18b32f8867becb18d1a22;p=git.git Merge branch 'maint' * maint: git-svn: avoid fetching files twice in the same revision --- 278fcd7debf19c1efee18b32f8867becb18d1a22 diff --cc git-svn.perl index 3891122d7,b53273eae..d0bd0bdeb --- a/git-svn.perl +++ b/git-svn.perl @@@ -2960,40 -2776,15 +2960,40 @@@ sub process_rm } sub libsvn_fetch { + $_xfer_delta ? libsvn_fetch_delta(@_) : libsvn_fetch_full(@_); +} + +sub libsvn_fetch_delta { + my ($last_commit, $paths, $rev, $author, $date, $msg) = @_; + my $pool = SVN::Pool->new; + my $ed = SVN::Git::Fetcher->new({ c => $last_commit, q => $_q }); + my $reporter = $SVN->do_update($rev, '', 1, $ed, $pool); + my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef) : (); + my (undef, $last_rev, undef) = cmt_metadata($last_commit); + $reporter->set_path('', $last_rev, 0, @lock, $pool); + $reporter->finish_report($pool); + $pool->clear; + unless ($ed->{git_commit_ok}) { + die "SVN connection failed somewhere...\n"; + } + libsvn_log_entry($rev, $author, $date, $msg, [$last_commit]); +} + +sub libsvn_fetch_full { my ($last_commit, $paths, $rev, $author, $date, $msg) = @_; open my $gui, '| git-update-index -z --index-info' or croak $!; - my @amr; + my %amr; + my $p = $SVN->{svn_path}; foreach my $f (keys %$paths) { my $m = $paths->{$f}->action(); - $f =~ s#^/+##; + if (length $p) { + $f =~ s#^/\Q$p\E/##; + next if $f =~ m#^/#; + } else { + $f =~ s#^/##; + } if ($m =~ /^[DR]$/) { - print "\t$m\t$f\n" unless $_q; - process_rm($gui, $last_commit, $f); + process_rm($gui, $last_commit, $f, $_q); next if $m eq 'D'; # 'R' can be file replacements, too, right? }