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;