mercurial/localrepo.py
changeset 24282 db8679812f84
parent 24281 e9ede9b4c2f8
child 24284 ff14b26fe5f4
--- a/mercurial/localrepo.py	Wed Dec 10 18:19:49 2014 -0800
+++ b/mercurial/localrepo.py	Mon Mar 09 22:36:56 2015 -0700
@@ -924,6 +924,16 @@
         # outdated when running hooks. As fncache is used for streaming clone,
         # this is not expected to break anything that happen during the hooks.
         tr.addfinalize('flush-fncache', self.store.write)
+        # we must avoid cyclic reference between repo and transaction.
+        reporef = weakref.ref(self)
+        def txnclosehook(tr2):
+            """To be run if transaction is successful, will schedule a hook run
+            """
+            def hook():
+                reporef().hook('txnclose', throw=False, txnname=desc,
+                               **tr2.hookargs)
+            reporef()._afterlock(hook)
+        tr.addfinalize('txnclose-hook', txnclosehook)
         self._transref = weakref.ref(tr)
         return tr