diff options
author | Eric Wong <normalperson@yhbt.net> | 2007-01-31 17:22:31 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2007-02-23 00:57:11 -0800 |
commit | 9c93fee51e26d5db82414317fa169294f3fa94b0 (patch) | |
tree | c4f152c0041e5f252a80635ed64ee9ce836860ca | |
parent | 373274f978a48b62549f20059bff630d85533533 (diff) | |
download | git-9c93fee51e26d5db82414317fa169294f3fa94b0.tar.gz git-9c93fee51e26d5db82414317fa169294f3fa94b0.tar.xz |
git-svn: avoid redundant get_log calls between invocations
Prefill .rev_db to the maximum revision we tried to fetch;
and take advantage of that so we can avoid using get_log()
on ranges we've already seen (and have deemed uninteresting).
Signed-off-by: Eric Wong <normalperson@yhbt.net>
-rwxr-xr-x | git-svn.perl | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/git-svn.perl b/git-svn.perl index 2206f1b25..b1d91fa47 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -655,18 +655,14 @@ sub fetch_all { my $ra = Git::SVN::Ra->new($url); my $head = $ra->get_latest_revnum; my $base = $head; - my $new_remote; foreach my $p (sort keys %$fetch) { my $gs = Git::SVN->new($fetch->{$p}, $repo_id, $p); - my $lr = $gs->last_rev; + my $lr = $gs->rev_db_max; if (defined $lr) { $base = $lr if ($lr < $base); - } else { - $new_remote = 1; } push @gs, $gs; } - $base = 0 if $new_remote; return if (++$base > $head); $ra->gs_fetch_loop_common($base, $head, @gs); } @@ -899,13 +895,17 @@ sub last_rev_commit { $rl = readline $fh; defined $rl or return (undef, undef); chomp $rl; - while ($c ne $rl && tell $fh != 0) { + while (('0' x40) eq $rl && tell $fh != 0) { $offset -= 41; seek $fh, $offset, 2; $rl = readline $fh; defined $rl or return (undef, undef); chomp $rl; } + if ($c) { + die "$self->{db_path} and ", $self->refname, + " inconsistent!:\n$c != $rl\n"; + } my $rev = tell $fh; croak $! if ($rev < 0); $rev = ($rev - 41) / 41; @@ -917,7 +917,7 @@ sub last_rev_commit { sub get_fetch_range { my ($self, $min, $max) = @_; $max ||= $self->ra->get_latest_revnum; - $min ||= $self->last_rev || 0; + $min ||= $self->rev_db_max; (++$min, $max); } @@ -1404,6 +1404,16 @@ sub rev_db_set { } } +sub rev_db_max { + my ($self) = @_; + my @stat = stat $self->{db_path} or + die "Couldn't stat $self->{db_path}: $!\n"; + ($stat[7] % 41) == 0 or + die "$self->{db_path} inconsistent size:$stat[7]\n"; + my $max = $stat[7] / 41; + (($max > 0) ? $max - 1 : 0); +} + sub rev_db_get { my ($self, $rev) = @_; my $ret; @@ -2404,6 +2414,12 @@ sub gs_fetch_loop_common { } } } + # pre-fill the .rev_db since it'll eventually get filled in + # with '0' x40 if something new gets committed + foreach my $gs (@gs) { + next if defined $gs->rev_db_get($max); + $gs->rev_db_set($max, 0 x40); + } last if $max >= $head; $min = $max + 1; $max += $inc; |