[PATCH 1 of 3] transaction: delete callbacks after use

Yuya Nishihara yuya at tcha.org
Wed May 31 09:10:20 EDT 2017


On Fri, 26 May 2017 17:42:34 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1495830441 25200
> #      Fri May 26 13:27:21 2017 -0700
> # Node ID 922d86488388b186fa407eae78fbb811c57a3293
> # Parent  ad37c569ec8121a99e4cd9da52365b114b82e744
> transaction: delete callbacks after use

Queued this, thanks.

> --- a/mercurial/transaction.py
> +++ b/mercurial/transaction.py
> @@ -431,6 +431,7 @@ class transaction(object):
>          '''commit the transaction'''
>          if self.count == 1:
>              self.validator(self)  # will raise exception if needed
> +            self.validator = None # Help prevent cycles.
>              self._generatefiles(group=gengroupprefinalize)
>              categories = sorted(self._finalizecallback)
>              for cat in categories:
> @@ -464,6 +465,7 @@ class transaction(object):
>          self._writeundo()
>          if self.after:
>              self.after()
> +            self.after = None # Help prevent cycles.
>          if self.opener.isfile(self._backupjournal):
>              self.opener.unlink(self._backupjournal)
>          if self.opener.isfile(self.journal):
> @@ -487,6 +489,7 @@ class transaction(object):
>          self.journal = None
>  
>          self.releasefn(self, True) # notify success of closing transaction
> +        self.releasefn = None # Help prevent cycles.

I prefer setting a null function to validator and releasefn as we do in
__init__, but they aren't called in __del__ (because journal is None), so
that shouldn't matter.


More information about the Mercurial-devel mailing list