summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorAndrew Myrick <amyrick@apple.com>2010-01-30 03:14:22 +0000
committerEric Wong <normalperson@yhbt.net>2010-02-04 23:33:25 -0800
commit8bff7c5383ed833bd1df9c8d85c00a27af3e5b02 (patch)
tree68ddf80a4d289017e233d20f911f65fb68d30ae4 /git-svn.perl
parent4d0cc2243778b38c3759c6a08f4f1ed64155a070 (diff)
downloadgit-8bff7c5383ed833bd1df9c8d85c00a27af3e5b02.tar.gz
git-svn: persistent memoization
Make memoization of the svn:mergeinfo processing functions persistent with Memoize::Storable so that the memoization tables don't need to be regenerated every time the user runs git-svn fetch. The Memoize::Storable hashes are stored in ENV{GIT_DIR}/svn/.caches. [ew: changed caches path to avoid conflicts with old repos] [ew: File::Path::{make_path => mkpath} for compatibility] [ew: line-wrapped at 80 chars] Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Andrew Myrick <amyrick@apple.com>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl40
1 files changed, 36 insertions, 4 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 4f7dc2b73b..265852f459 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1656,6 +1656,7 @@ use File::Path qw/mkpath/;
use File::Copy qw/copy/;
use IPC::Open3;
use Memoize; # core since 5.8.0, Jul 2002
+use Memoize::Storable;
my ($_gc_nr, $_gc_period);
@@ -3116,10 +3117,39 @@ sub has_no_changes {
command_oneline("rev-parse", "$commit~1^{tree}"));
}
-BEGIN {
- memoize 'lookup_svn_merge';
- memoize 'check_cherry_pick';
- memoize 'has_no_changes';
+# The GIT_DIR environment variable is not always set until after the command
+# line arguments are processed, so we can't memoize in a BEGIN block.
+{
+ my $memoized = 0;
+
+ sub memoize_svn_mergeinfo_functions {
+ return if $memoized;
+ $memoized = 1;
+
+ my $cache_path = "$ENV{GIT_DIR}/svn/.caches/";
+ mkpath([$cache_path]) unless -d $cache_path;
+
+ tie my %lookup_svn_merge_cache => 'Memoize::Storable',
+ "$cache_path/lookup_svn_merge.db", 'nstore';
+ memoize 'lookup_svn_merge',
+ SCALAR_CACHE => 'FAULT',
+ LIST_CACHE => ['HASH' => \%lookup_svn_merge_cache],
+ ;
+
+ tie my %check_cherry_pick_cache => 'Memoize::Storable',
+ "$cache_path/check_cherry_pick.db", 'nstore';
+ memoize 'check_cherry_pick',
+ SCALAR_CACHE => 'FAULT',
+ LIST_CACHE => ['HASH' => \%check_cherry_pick_cache],
+ ;
+
+ tie my %has_no_changes_cache => 'Memoize::Storable',
+ "$cache_path/has_no_changes.db", 'nstore';
+ memoize 'has_no_changes',
+ SCALAR_CACHE => ['HASH' => \%has_no_changes_cache],
+ LIST_CACHE => 'FAULT',
+ ;
+ }
}
sub parents_exclude {
@@ -3163,6 +3193,8 @@ sub find_extra_svn_parents {
my ($self, $ed, $mergeinfo, $parents) = @_;
# aha! svk:merge property changed...
+ memoize_svn_mergeinfo_functions();
+
# We first search for merged tips which are not in our
# history. Then, we figure out which git revisions are in
# that tip, but not this revision. If all of those revisions