# HG changeset patch # User Gregory Szorc # Date 2016-04-16 16:00:15 # Node ID 518c3e392f75f61652ba575d81b8aa04d1cbdf3d # Parent 77e566fe31ec0421a5f78d155f660503eb4d2a81 lock: clear postrelease hooks list after usage Post release hooks should only be called once. Setting the list to None after usage will prevent accidental usage after they are used. In addition, it is easy for reference cycles to sneak into hook functions. Clearing the hooks after usage helps prevent these cycles. diff --git a/mercurial/lock.py b/mercurial/lock.py --- a/mercurial/lock.py +++ b/mercurial/lock.py @@ -234,6 +234,8 @@ class lock(object): if not self._parentheld: for callback in self.postrelease: callback() + # Prevent double usage and help clear cycles. + self.postrelease = None def release(*locks): for lock in locks: