From: Junio C Hamano Date: Thu, 27 Oct 2016 22:04:08 +0000 (-0700) Subject: Merge branch 'svn-cache' of git://bogomips.org/git-svn X-Git-Tag: v2.11.0-rc0~14 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a3228e4a4a621b63419c3e936211a7e1c9cb67a9?ds=inline;hp=-c Merge branch 'svn-cache' of git://bogomips.org/git-svn * 'svn-cache' of git://bogomips.org/git-svn: git-svn: do not reuse caches memoized for a different architecture --- a3228e4a4a621b63419c3e936211a7e1c9cb67a9 diff --combined perl/Git/SVN.pm index 499e84b6d6,b3c146011a..711d2687a3 --- a/perl/Git/SVN.pm +++ b/perl/Git/SVN.pm @@@ -807,15 -807,10 +807,15 @@@ sub get_fetch_range (++$min, $max); } +sub svn_dir { + command_oneline(qw(rev-parse --git-path svn)); +} + sub tmp_config { my (@args) = @_; - my $old_def_config = "$ENV{GIT_DIR}/svn/config"; - my $config = "$ENV{GIT_DIR}/svn/.metadata"; + my $svn_dir = svn_dir(); + my $old_def_config = "$svn_dir/config"; + my $config = "$svn_dir/.metadata"; if (! -f $config && -f $old_def_config) { rename $old_def_config, $config or die "Failed rename $old_def_config => $config: $!\n"; @@@ -1663,7 -1658,17 +1663,17 @@@ sub tie_for_persistent_memoization if ($memo_backend > 0) { tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml"; } else { - tie %$hash => 'Memoize::Storable', "$path.db", 'nstore'; + # first verify that any existing file can actually be loaded + # (it may have been saved by an incompatible version) + my $db = "$path.db"; + if (-e $db) { + use Storable qw(retrieve); + + if (!eval { retrieve($db); 1 }) { + unlink $db or die "unlink $db failed: $!"; + } + } + tie %$hash => 'Memoize::Storable', $db, 'nstore'; } } @@@ -1676,7 -1681,7 +1686,7 @@@ return if $memoized; $memoized = 1; - my $cache_path = "$ENV{GIT_DIR}/svn/.caches/"; + my $cache_path = svn_dir() . '/.caches/'; mkpath([$cache_path]) unless -d $cache_path; my %lookup_svn_merge_cache; @@@ -1717,7 -1722,7 +1727,7 @@@ sub clear_memoized_mergeinfo_caches { die "Only call this method in non-memoized context" if ($memoized); - my $cache_path = "$ENV{GIT_DIR}/svn/.caches/"; + my $cache_path = svn_dir() . '/.caches/'; return unless -d $cache_path; for my $cache_file (("$cache_path/lookup_svn_merge", @@@ -2451,13 -2456,12 +2461,13 @@@ sub _new "refs/remotes/$prefix$default_ref_id"; } $_[1] = $repo_id; - my $dir = "$ENV{GIT_DIR}/svn/$ref_id"; + my $svn_dir = svn_dir(); + my $dir = "$svn_dir/$ref_id"; - # Older repos imported by us used $GIT_DIR/svn/foo instead of - # $GIT_DIR/svn/refs/remotes/foo when tracking refs/remotes/foo + # Older repos imported by us used $svn_dir/foo instead of + # $svn_dir/refs/remotes/foo when tracking refs/remotes/foo if ($ref_id =~ m{^refs/remotes/(.+)}) { - my $old_dir = "$ENV{GIT_DIR}/svn/$1"; + my $old_dir = "$svn_dir/$1"; if (-d $old_dir && ! -d $dir) { $dir = $old_dir; } @@@ -2467,7 -2471,7 +2477,7 @@@ mkpath([$dir]); my $obj = bless { ref_id => $ref_id, dir => $dir, index => "$dir/index", - config => "$ENV{GIT_DIR}/svn/config", + config => "$svn_dir/config", map_root => "$dir/.rev_map", repo_id => $repo_id }, $class; # Ensure it gets canonicalized