From: Eric Wong <e@80x24.org>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org, Gavin Lambert <github@mirality.co.nz>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git-svn: do not reuse caches memoized for a different architecture
Date: Tue, 25 Oct 2016 21:23:57 +0000 [thread overview]
Message-ID: <20161025212357.GA8683@starla> (raw)
In-Reply-To: <653aa0cd566a2486bbc38cfd82ddfcfdfe48271c.1477398004.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> wrote:
> +++ 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.
next prev parent reply other threads:[~2016-10-25 21:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-25 15:30 [PATCH] git-svn: do not reuse caches memoized for a different architecture Johannes Schindelin
2016-10-25 21:23 ` Eric Wong [this message]
2016-10-27 19:44 ` Junio C Hamano
2016-10-27 20:51 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161025212357.GA8683@starla \
--to=e@80x24.org \
--cc=git@vger.kernel.org \
--cc=github@mirality.co.nz \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).