diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-04-28 03:51:16 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-06-16 03:04:20 -0700 |
commit | 098749d9bee6694abc8a0991996ff94b607abc7f (patch) | |
tree | 0c5cbf4955e27054dee8d5da95cecccbea2e2d42 /contrib/git-svn | |
parent | bf78b1d89b29f8524ccfbd7042fa277277e316ff (diff) | |
download | git-098749d9bee6694abc8a0991996ff94b607abc7f.tar.gz git-098749d9bee6694abc8a0991996ff94b607abc7f.tar.xz |
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>
Diffstat (limited to 'contrib/git-svn')
-rwxr-xr-x | contrib/git-svn/git-svn.perl | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl index c91160d37..d4b932369 100755 --- a/contrib/git-svn/git-svn.perl +++ b/contrib/git-svn/git-svn.perl @@ -1220,23 +1220,30 @@ sub check_upgrade_needed { # fills %tree_map with a reverse mapping of trees to commits. Useful # for finding parents to commit on. sub map_tree_joins { + my %seen; foreach my $br (@_branch_from) { my $pid = open my $pipe, '-|'; defined $pid or croak $!; if ($pid == 0) { - exec(qw(git-rev-list --pretty=raw), $br) or croak $?; + exec(qw(git-rev-list --topo-order --pretty=raw), $br) + or croak $?; } while (<$pipe>) { if (/^commit ($sha1)$/o) { my $commit = $1; + + # if we've seen a commit, + # we've seen its parents + last if $seen{$commit}; my ($tree) = (<$pipe> =~ /^tree ($sha1)$/o); unless (defined $tree) { die "Failed to parse commit $commit\n"; } push @{$tree_map{$tree}}, $commit; + $seen{$commit} = 1; } } - close $pipe or croak $?; + close $pipe; # we could be breaking the pipe early } } |