Skip to content

Commit b21c0bc

Browse files
committed
Merge git://git.bogomips.org/git-svn
* 'master' of git://git.bogomips.org/git-svn: git-svn: memoize _rev_list and rebuild
2 parents 2dbfa67 + ab0bcec commit b21c0bc

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

perl/Git/SVN.pm

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ sub tie_for_persistent_memoization {
15991599
my %lookup_svn_merge_cache;
16001600
my %check_cherry_pick_cache;
16011601
my %has_no_changes_cache;
1602+
my %_rev_list_cache;
16021603

16031604
tie_for_persistent_memoization(\%lookup_svn_merge_cache,
16041605
"$cache_path/lookup_svn_merge");
@@ -1620,6 +1621,14 @@ sub tie_for_persistent_memoization {
16201621
SCALAR_CACHE => ['HASH' => \%has_no_changes_cache],
16211622
LIST_CACHE => 'FAULT',
16221623
;
1624+
1625+
tie_for_persistent_memoization(\%_rev_list_cache,
1626+
"$cache_path/_rev_list");
1627+
memoize '_rev_list',
1628+
SCALAR_CACHE => 'FAULT',
1629+
LIST_CACHE => ['HASH' => \%_rev_list_cache],
1630+
;
1631+
16231632
}
16241633

16251634
sub unmemoize_svn_mergeinfo_functions {
@@ -1629,6 +1638,7 @@ sub tie_for_persistent_memoization {
16291638
Memoize::unmemoize 'lookup_svn_merge';
16301639
Memoize::unmemoize 'check_cherry_pick';
16311640
Memoize::unmemoize 'has_no_changes';
1641+
Memoize::unmemoize '_rev_list';
16321642
}
16331643

16341644
sub clear_memoized_mergeinfo_caches {
@@ -1959,11 +1969,25 @@ sub rebuild_from_rev_db {
19591969
unlink $path or croak "unlink: $!";
19601970
}
19611971

1972+
#define a global associate map to record rebuild status
1973+
my %rebuild_status;
1974+
#define a global associate map to record rebuild verify status
1975+
my %rebuild_verify_status;
1976+
19621977
sub rebuild {
19631978
my ($self) = @_;
19641979
my $map_path = $self->map_path;
19651980
my $partial = (-e $map_path && ! -z $map_path);
1966-
return unless ::verify_ref($self->refname.'^0');
1981+
my $verify_key = $self->refname.'^0';
1982+
if (!$rebuild_verify_status{$verify_key}) {
1983+
my $verify_result = ::verify_ref($verify_key);
1984+
if ($verify_result) {
1985+
$rebuild_verify_status{$verify_key} = 1;
1986+
}
1987+
}
1988+
if (!$rebuild_verify_status{$verify_key}) {
1989+
return;
1990+
}
19671991
if (!$partial && ($self->use_svm_props || $self->no_metadata)) {
19681992
my $rev_db = $self->rev_db_path;
19691993
$self->rebuild_from_rev_db($rev_db);
@@ -1977,10 +2001,21 @@ sub rebuild {
19772001
print "Rebuilding $map_path ...\n" if (!$partial);
19782002
my ($base_rev, $head) = ($partial ? $self->rev_map_max_norebuild(1) :
19792003
(undef, undef));
2004+
my $key_value = ($head ? "$head.." : "") . $self->refname;
2005+
if (exists $rebuild_status{$key_value}) {
2006+
print "Done rebuilding $map_path\n" if (!$partial || !$head);
2007+
my $rev_db_path = $self->rev_db_path;
2008+
if (-f $self->rev_db_path) {
2009+
unlink $self->rev_db_path or croak "unlink: $!";
2010+
}
2011+
$self->unlink_rev_db_symlink;
2012+
return;
2013+
}
19802014
my ($log, $ctx) =
1981-
command_output_pipe(qw/rev-list --pretty=raw --reverse/,
1982-
($head ? "$head.." : "") . $self->refname,
2015+
command_output_pipe(qw/rev-list --pretty=raw --reverse/,
2016+
$key_value,
19832017
'--');
2018+
$rebuild_status{$key_value} = 1;
19842019
my $metadata_url = $self->metadata_url;
19852020
remove_username($metadata_url);
19862021
my $svn_uuid = $self->rewrite_uuid || $self->ra_uuid;

0 commit comments

Comments
 (0)