Mercurial > hg
changeset 26474:431094a3b21f
lock.release: don't call postrelease functions for inherited locks
Review feedback from Pierre-Yves David. The postrelease functions typically
assume the lock is not held at all.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 04 Oct 2015 20:04:44 -0700 |
parents | 5f94e64f182c |
children | efd57cd6fd1d |
files | mercurial/lock.py tests/test-lock.py |
diffstat | 2 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/lock.py Sun Oct 04 20:02:50 2015 -0700 +++ b/mercurial/lock.py Sun Oct 04 20:04:44 2015 -0700 @@ -221,8 +221,11 @@ self.vfs.unlink(self.f) except OSError: pass - for callback in self.postrelease: - callback() + # The postrelease functions typically assume the lock is not held + # at all. + if not self._parentheld: + for callback in self.postrelease: + callback() def release(*locks): for lock in locks:
--- a/tests/test-lock.py Sun Oct 04 20:02:50 2015 -0700 +++ b/tests/test-lock.py Sun Oct 04 20:04:44 2015 -0700 @@ -169,7 +169,7 @@ childlock.release() childstate.assertreleasecalled(True) - childstate.assertpostreleasecalled(True) + childstate.assertpostreleasecalled(False) childstate.assertlockexists(True) parentstate.resetacquirefn() @@ -208,7 +208,7 @@ lock2.release() state2.assertreleasecalled(True) - state2.assertpostreleasecalled(True) + state2.assertpostreleasecalled(False) state2.assertlockexists(True) state1.resetacquirefn() @@ -217,7 +217,7 @@ lock1.release() state1.assertreleasecalled(True) - state1.assertpostreleasecalled(True) + state1.assertpostreleasecalled(False) state1.assertlockexists(True) lock0.release() @@ -245,7 +245,7 @@ # release the child lock childlock.release() childstate.assertreleasecalled(True) - childstate.assertpostreleasecalled(True) + childstate.assertpostreleasecalled(False) childstate.assertlockexists(True) parentlock.release()