transaction: clear callback instances after usage
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 16 Apr 2016 09:02:37 -0700
changeset 28960 14e683d6b273
parent 28959 518c3e392f75
child 28961 2e58dc022caa
transaction: clear callback instances after usage Prevents double usage and helps reduce reference cycles, which were observed to occur in `hg convert` and other scenarios where there are multiple transactions per process.
mercurial/transaction.py
--- a/mercurial/transaction.py	Sat Apr 16 09:00:15 2016 -0700
+++ b/mercurial/transaction.py	Sat Apr 16 09:02:37 2016 -0700
@@ -431,6 +431,8 @@
             categories = sorted(self._finalizecallback)
             for cat in categories:
                 self._finalizecallback[cat](self)
+            # Prevent double usage and help clear cycles.
+            self._finalizecallback = None
             self._generatefiles(group=GenerationGroup.POSTFINALIZE)
 
         self.count -= 1
@@ -486,6 +488,8 @@
         categories = sorted(self._postclosecallback)
         for cat in categories:
             self._postclosecallback[cat](self)
+        # Prevent double usage and help clear cycles.
+        self._postclosecallback = None
 
     @active
     def abort(self):
@@ -539,6 +543,8 @@
             try:
                 for cat in sorted(self._abortcallback):
                     self._abortcallback[cat](self)
+                # Prevent double usage and help clear cycles.
+                self._abortcallback = None
                 _playback(self.journal, self.report, self.opener, self._vfsmap,
                           self.entries, self._backupentries, False)
                 self.report(_("rollback completed\n"))