summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 373274f)
raw | patch | inline | side by side (parent: 373274f)
author | Eric Wong <normalperson@yhbt.net> | |
Thu, 1 Feb 2007 01:22:31 +0000 (17:22 -0800) | ||
committer | Eric Wong <normalperson@yhbt.net> | |
Fri, 23 Feb 2007 08:57:11 +0000 (00:57 -0800) |
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>
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>
git-svn.perl | patch | blob | history |
diff --git a/git-svn.perl b/git-svn.perl
index 2206f1b250125eb9f9d27b87c505b66bb7af531b..b1d91fa471b11ef6ab2f9c005bb1efac6ea53119 100755 (executable)
--- a/git-svn.perl
+++ b/git-svn.perl
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);
}
$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;
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);
}
}
}
+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;
}
}
}
+ # 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;