git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Wong <e@80x24.org>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
	git@vger.kernel.org, Gavin Lambert <github@mirality.co.nz>
Subject: Re: [PATCH] git-svn: do not reuse caches memoized for a different architecture
Date: Thu, 27 Oct 2016 12:44:38 -0700	[thread overview]
Message-ID: <xmqqmvhp60gp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161025212357.GA8683@starla> (Eric Wong's message of "Tue, 25 Oct 2016 21:23:57 +0000")

Eric Wong <e@80x24.org> writes:

> 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.

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.

  reply	other threads:[~2016-10-27 19:44 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
2016-10-27 19:44   ` Junio C Hamano [this message]
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=xmqqmvhp60gp.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    --cc=github@mirality.co.nz \
    --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).