lock: clear postrelease hooks list after usage
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 16 Apr 2016 09:00:15 -0700
changeset 28959 518c3e392f75
parent 28958 77e566fe31ec
child 28960 14e683d6b273
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.
mercurial/lock.py
--- a/mercurial/lock.py	Sun Mar 27 21:05:55 2016 +0900
+++ b/mercurial/lock.py	Sat Apr 16 09:00:15 2016 -0700
@@ -234,6 +234,8 @@
             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: