Re: [PATCH] git-svn: do not reuse caches memoized for a different architecture

2 messages, 2 authors, 2016-10-27 · open the first message on its own page

Re: [PATCH] git-svn: do not reuse caches memoized for a different architecture

From: Junio C Hamano <hidden>
Date: 2016-10-27 19:45:00

Eric Wong [off-list ref] writes:
quoted hunk
Johannes Schindelin [off-list ref] wrote:
quoted
+++ b/perl/Git/SVN.pm
@@ -1658,6 +1658,11 @@ sub tie_for_persistent_memoization {
 	if ($memo_backend > 0) {
 		tie %$hash => 'Git::SVN::Memoize::YAML', "$path.yaml";
 	} else {
+		# first verify that any existing file can actually be loaded
+		# (it may have been saved by an incompatible version)
+		if (-e "$path.db") {
+			unlink "$path.db" unless eval { retrieve("$path.db"); 1 };
+		}
That retrieve() call is unlikely to work without "use Storable"
to import it into the current package.

I also favor setting "$path.db" once to detect typos and avoid
going over 80 columns.  Additionally, having error-checking for
unlink might be useful.

So perhaps squashing this on top:
diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index 025c894..b3c1460 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -1660,10 +1660,15 @@ sub tie_for_persistent_memoization {
 	} else {
 		# first verify that any existing file can actually be loaded
 		# (it may have been saved by an incompatible version)
-		if (-e "$path.db") {
-			unlink "$path.db" unless eval { retrieve("$path.db"); 1 };
+		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', "$path.db", 'nstore';
+		tie %$hash => 'Memoize::Storable', $db, 'nstore';
 	}
 }
 
Thoughts?  Thanks.
Just peeking from the sideline, but the your squash looks like an
improvement to me.

Hopefully the final version after your interaction with Dscho can
come to me via another "pull this now"?

Thanks.

Re: [PATCH] git-svn: do not reuse caches memoized for a different architecture

From: Eric Wong <hidden>
Date: 2016-10-27 20:51:22

Junio C Hamano [off-list ref] wrote:
Just peeking from the sideline, but the your squash looks like an
improvement to me.
Thanks.
Hopefully the final version after your interaction with Dscho can
come to me via another "pull this now"?
Not sure if I'll be online the next few days,
but I've preeptively pushed the patch + squash to my repo:

The following changes since commit 2cc2e70264e0fcba04f9ef791d144bbc8b501206:

  Eleventh batch for 2.11 (2016-10-26 13:28:47 -0700)

are available in the git repository at:

  git://bogomips.org/git-svn.git svn-cache

for you to fetch changes up to a2c761ce5b7a5fd8b505b036f3509a9e6617dee8:

  git-svn: do not reuse caches memoized for a different architecture (2016-10-27 20:17:36 +0000)

----------------------------------------------------------------
Gavin Lambert (1):
      git-svn: do not reuse caches memoized for a different architecture

 perl/Git/SVN.pm | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help