diff mercurial/changelog.py @ 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 3872d563e01a
children b01c491af0cf
line wrap: on
line diff
--- 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