Skip to content

Commit

Permalink
git-svn: cache max revision in rev_db databases
Browse files Browse the repository at this point in the history
Cache the maximum revision for each rev_db URL rather than looking it
up each time.  This saves a lot of time when rebuilding indexes on a
freshly cloned repository.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Sam Vilain authored and Junio C Hamano committed Jul 1, 2007
1 parent 3dfab99 commit 40cb8f8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ sub working_head_info {
my ($head, $refs) = @_;
my ($fh, $ctx) = command_output_pipe('log', $head);
my $hash;
my %max;
while (<$fh>) {
if ( m{^commit ($::sha1)$} ) {
unshift @$refs, $hash if $hash and $refs;
Expand All @@ -815,11 +816,14 @@ sub working_head_info {
next unless s{^\s*(git-svn-id:)}{$1};
my ($url, $rev, $uuid) = extract_metadata($_);
if (defined $url && defined $rev) {
next if $max{$url} and $max{$url} < $rev;
if (my $gs = Git::SVN->find_by_url($url)) {
my $c = $gs->rev_db_get($rev);
if ($c && $c eq $hash) {
close $fh; # break the pipe
return ($url, $rev, $uuid, $gs);
} else {
$max{$url} ||= $gs->rev_db_max;
}
}
}
Expand Down

0 comments on commit 40cb8f8

Please sign in to comment.