[PATCH] localrepo: prevent leak of transaction object (issue4258)

Gregory Szorc gregory.szorc at gmail.com
Wed May 21 20:02:58 CDT 2014

# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1400720555 25200
#      Wed May 21 18:02:35 2014 -0700
# Node ID 86829970c3fbf3134560a143f74444066d2e9623
# Parent  9fb6f328576ac4e38f4e5071c4d669a6ceb3a76e
localrepo: prevent leak of transaction object (issue4258)

The onclose() closure added in cd443c7589cc held a regular reference to
the transaction object. This was causing the transaction to not gc and
a leak to occur.

The closure now holds a reference to the weakref instance and the leak
goes away.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -860,9 +860,9 @@ class localrepository(object):
                 _("abandoned transaction found"),
                 hint=_("run 'hg recover' to clean up transaction"))
         def onclose():
-            self.store.write(tr)
+            self.store.write(self._transref())
         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
         rp = report and report or self.ui.warn

More information about the Mercurial-devel mailing list