@matheusbsbs / matheus-bagliano / commits / 098749d9be
Fork 0

git-svn: optimize --branch and --branch-all-ref

By breaking the pipe read once we've seen a commit twice. This should make -B/--branch-all-ref faster and usable on a frequent basis. We use topological order now for calling git-rev-list, and any commit we've seen before should imply that all parents have been seen (at least I hope that's the case for --topo-order). Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Apr 28, 2006 at 03:51 UTC 098749d9bee6694abc8a0991996ff94b607abc7f
1 file changed +9 -2
contrib/git-svn/git-svn.perl
+9 -2
@@ -1220,23 +1220,30 @@ sub check_upgrade_needed {
1220 # fills %tree_map with a reverse mapping of trees to commits. Useful
1221 # for finding parents to commit on.
1222 sub map_tree_joins {
1223 + my %seen;
1224 foreach my $br (@_branch_from) {
1225 my $pid = open my $pipe, '-|';
1226 defined $pid or croak $!;
1227 if ($pid == 0) {
1227 - exec(qw(git-rev-list --pretty=raw), $br) or croak $?;
1228 + exec(qw(git-rev-list --topo-order --pretty=raw), $br)
1229 + or croak $?;
1230 }
1231 while (<$pipe>) {
1232 if (/^commit ($sha1)$/o) {
1233 my $commit = $1;
1234 +
1235 + # if we've seen a commit,
1236 + # we've seen its parents
1237 + last if $seen{$commit};
1238 my ($tree) = (<$pipe> =~ /^tree ($sha1)$/o);
1239 unless (defined $tree) {
1240 die "Failed to parse commit $commit\n";
1241 }
1242 push @{$tree_map{$tree}}, $commit;
1243 + $seen{$commit} = 1;
1244 }
1245 }
1239 - close $pipe or croak $?;
1246 + close $pipe; # we could be breaking the pipe early
1247 }
1248 }
1249