Merge branch 'svn-cache' of git://bogomips.org/git-svn
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Oct 2016 22:04:08 +0000 (15:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Oct 2016 22:04:08 +0000 (15:04 -0700)
* 'svn-cache' of git://bogomips.org/git-svn:
git-svn: do not reuse caches memoized for a different architecture

1  2 
perl/Git/SVN.pm
diff --combined perl/Git/SVN.pm
index 499e84b6d6787fe70332e85dc887f2fa14a18ea7,b3c146011abcf7c088a9be61688a37922ee90fe7..711d2687a3005091d80fc964e5fd92aba6167b38
@@@ -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';
        }
  }
  
                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;
        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;
                }
        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