зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
373274f978
Коммит
9c93fee51e
30
git-svn.perl
30
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче