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.
--- 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()