From: Peter Baumann <waste.manager@gmx.de>
To: Eric Wong <normalperson@yhbt.net>
Cc: git@vger.kernel.org, Andrew Myrick <amyrick@apple.com>,
Jonathan Nieder <jrnieder@gmail.com>,
Steven Walter <stevenrwalter@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] git svn: reset invalidates the memoized mergeinfo caches
Date: Wed, 8 Aug 2012 07:41:29 +0200 [thread overview]
Message-ID: <20120808054129.GB10899@m62s10.vlinux.de> (raw)
In-Reply-To: <20120807204510.GA10453@dcvr.yhbt.net>
On Tue, Aug 07, 2012 at 08:45:10PM +0000, Eric Wong wrote:
> Peter Baumann <waste.manager@gmx.de> wrote:
> > Therefore the easiest solution to clear the cache is to delete the files
> > on disk in 'git svn reset'. Normally, deleting the files behind the back
> > of the memoization module would be problematic, because the in-memory
> > representation would still exist and contain wrong data. Fortunately, the
> > memoization is active in memory only for a small portion of the code.
> > Invalidating the cache by deleting the files on disk if it isn't active
> > should be safe.
>
> Thanks for the patch and explanation. A few comments below:
>
> > + sub clear_memoized_mergeinfo_caches {
> > + die "Only call this method in non-memoized context" if ($memoized);
> > +
> > + my $cache_path = "$ENV{GIT_DIR}/svn/.caches/";
> > + return unless -d $cache_path;
> > +
> > + for my $cache_file (("$cache_path/lookup_svn_merge",
> > + "$cache_path/check_cherry_pick",
> > + "$cache_path/has_no_changes")) {
> > + for my $suffix (qw(yaml db)) {
> > + unlink("$cache_file.$suffix");
>
> Need to check for unlink() errors (and ignore ENOENT).
I'm not sure what you mean here: Aren't we screwed either way if unlinking
the file failed? There is nothhing we can do about it if e.g. the user doesn't
have the permissions to delete the file, besides terminating, e.g.
for my $cache_file (("$cache_path/lookup_svn_merge",
"$cache_path/check_cherry_pick",
"$cache_path/has_no_changes")) {
for my $suffix (qw(yaml db)) {
next unless (-e "$cache_file.$suffix");
unlink("$cache_file.$suffix") or
die "Failed to delete $cache_file.$suffix";
}
}
>
> > @@ -2126,8 +2142,13 @@ sub rev_map_set {
> >
> > sysopen(my $fh, $db_lock, O_RDWR | O_CREAT)
> > or croak "Couldn't open $db_lock: $!\n";
> > - $update_ref eq 'reset' ? _rev_map_reset($fh, $rev, $commit) :
> > - _rev_map_set($fh, $rev, $commit);
> > + if ($update_ref eq 'reset') {
> > + _rev_map_reset($fh, $rev, $commit);
> > + clear_memoized_mergeinfo_caches();
>
> Better to clear_memoized_mergeinfo_caches() before _rev_map_reset()
> in case unlink() (or anything else) fails when clearing the cache.
Will do.
>
> > +test_expect_success 'initialize source svn repo' '
> > + svn_cmd mkdir -m "create trunk" "$svnrepo"/trunk &&
> > + svn_cmd mkdir -m "create branches" "$svnrepo/branches" &&
> > + svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
> > + (
> > + cd "$SVN_TREE" &&
> > + touch foo &&
> > + svn add foo &&
>
> svn_cmd here, too.
Will do.
>
> > + svn commit -m "a" &&
> > + svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
> > + svn switch "$svnrepo"/branches/branch1 &&
> > + touch bar &&
> > + svn add bar &&
> > + svn commit -m b &&
> > + svn switch "$svnrepo"/trunk &&
> > + touch baz &&
> > + svn add baz &&
> > + svn commit -m c &&
> > + svn up &&
> > + svn merge "$svnrepo"/branches/branch1 &&
> > + svn commit -m "m"
> > + ) &&
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2012-08-08 5:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 20:02 [PATCH] git svn: reset invalidates the memoized mergeinfo caches Peter Baumann
2012-08-07 20:45 ` Eric Wong
2012-08-08 5:41 ` Peter Baumann [this message]
2012-08-08 22:52 ` Eric Wong
2012-08-09 6:42 ` [PATCH v2] " Peter Baumann
2012-08-09 17:35 ` Steven Walter
2012-08-10 20:22 ` Eric Wong
2012-08-10 21:29 ` Junio C Hamano
2012-08-10 21:30 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120808054129.GB10899@m62s10.vlinux.de \
--to=waste.manager@gmx.de \
--cc=amyrick@apple.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=normalperson@yhbt.net \
--cc=stevenrwalter@gmail.com \
/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.
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 NNTP newsgroup(s).