[PATCH 5 of 5] changelog: rely on transaction for finalization
Matt Mackall
mpm at selenic.com
Wed Nov 5 18:28:16 CST 2014
On Sun, 2014-11-02 at 14:20 +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1413619781 25200
> # Sat Oct 18 01:09:41 2014 -0700
> # Node ID 3270e2ef0b7d74003e49fcdec588763c258a1038
> # Parent d434fffe10dac3cb137b3695426a69a4cef9ef35
> changelog: rely on transaction for finalization
I've queued the first four patches here, thanks. But I can't work out by
inspection why the weakref is essential, so it needs inline
justification. We'd really prefer to avoid the weakref if at all
possible, of course.
> Instead of calling `cl.finalize()` by hand (possibly at a bogus time) we
> register it to the transaction during `delayupdate` and rely on `tr.close()` to
> call it at the right time.
>
> diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
> --- a/mercurial/changegroup.py
> +++ b/mercurial/changegroup.py
> @@ -720,12 +720,10 @@ def addchangegroup(repo, source, srctype
> # publishing only alter behavior during push
> #
> # strip should not touch boundary at all
> phases.retractboundary(repo, tr, targetphase, added)
>
> - # make changelog see real files again
> - cl.finalize(trp)
>
> tr.close()
>
> if changesets > 0:
> if srctype != 'strip':
> diff --git a/mercurial/changelog.py b/mercurial/changelog.py
> --- a/mercurial/changelog.py
> +++ b/mercurial/changelog.py
> @@ -3,10 +3,11 @@
> # Copyright 2005-2007 Matt Mackall <mpm at selenic.com>
> #
> # This software may be used and distributed according to the terms of the
> # GNU General Public License version 2 or any later version.
>
> +import weakref
> from node import bin, hex, nullid
> from i18n import _
> import util, error, revlog, encoding
>
> _defaultextra = {'branch': 'default'}
> @@ -237,12 +238,14 @@ class changelog(revlog.revlog):
> self._delaybuf = []
> self.opener = _delayopener(self._realopener, self.indexfile,
> self._delaybuf)
> self._delayed = True
> tr.addpending('cl-%i' % id(self), self._writepending)
> + trp = weakref.proxy(tr)
> + tr.addfinalize('cl-%i' % id(self), lambda: self._finalize(trp))
>
> - def finalize(self, tr):
> + def _finalize(self, tr):
> "finalize index updates"
> self._delayed = False
> self.opener = self._realopener
> # move redirected index data back into place
> if self._divert:
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1443,11 +1443,10 @@ class localrepository(object):
> user, ctx.date(), ctx.extra().copy())
> p = lambda: tr.writepending() and self.root or ""
> xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
> self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
> parent2=xp2, pending=p)
> - self.changelog.finalize(trp)
> # set the new commit is proper phase
> targetphase = subrepo.newcommitphase(self.ui, ctx)
> if targetphase:
> # retract boundary do not alter parent changeset.
> # if a parent have higher the resulting phase will
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list