git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
EWEric Wong <e@80x24.org>
Date
Oct 25, 2016, 21:23 UTC
Message-ID
<20161025212357.GA8683@starla>
In-Reply-To
<653aa0cd566a2486bbc38cfd82ddfcfdfe48271c.1477398004.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> wrote:
Show 10 quoted lines
> +++ 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.
Previous: Johannes SchindelinNext: Junio C Hamano
Message 2 of 4 in “git-svn: do not reuse caches memoized for a different architecture”
  1. git-svn: do not reuse caches memoized for a different architectureJohannes Schindelin, Oct 25, 2016
  2. Eric WongOct 25, 2016
  3. Junio C HamanoOct 27, 2016
  4. Eric WongOct 27, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.