changeset 23205:2d54aa5397cd

changelog: rely on transaction for finalization Instead of calling 'cl.finalize()' by hand (possibly at a bogus time) we register it in the transaction during 'delayupdate' and rely on 'tr.close()' to call it at the right time.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 18 Oct 2014 01:09:41 -0700
parents 10beda5bd2b7
children ca38764e2f38
files mercurial/changegroup.py mercurial/changelog.py mercurial/localrepo.py
diffstat 3 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changegroup.py	Fri Oct 17 22:28:09 2014 -0700
+++ b/mercurial/changegroup.py	Sat Oct 18 01:09:41 2014 -0700
@@ -788,8 +788,6 @@
             # strip should not touch boundary at all
             phases.retractboundary(repo, tr, targetphase, added)
 
-        # make changelog see real files again
-        cl.finalize(trp)
 
         tr.close()
 
--- a/mercurial/changelog.py	Fri Oct 17 22:28:09 2014 -0700
+++ b/mercurial/changelog.py	Sat Oct 18 01:09:41 2014 -0700
@@ -5,6 +5,7 @@
 # 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
@@ -239,8 +240,10 @@
                                            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
--- a/mercurial/localrepo.py	Fri Oct 17 22:28:09 2014 -0700
+++ b/mercurial/localrepo.py	Sat Oct 18 01:09:41 2014 -0700
@@ -1445,7 +1445,6 @@
             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: