diff --git a/mercurial/lock.py b/mercurial/lock.py
--- a/mercurial/lock.py
+++ b/mercurial/lock.py
@@ -221,8 +221,11 @@ class lock(object):
                         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:
diff --git a/tests/test-lock.py b/tests/test-lock.py
--- a/tests/test-lock.py
+++ b/tests/test-lock.py
@@ -169,7 +169,7 @@ class testlock(unittest.TestCase):
 
             childlock.release()
             childstate.assertreleasecalled(True)
-            childstate.assertpostreleasecalled(True)
+            childstate.assertpostreleasecalled(False)
             childstate.assertlockexists(True)
 
             parentstate.resetacquirefn()
@@ -208,7 +208,7 @@ class testlock(unittest.TestCase):
 
                 lock2.release()
                 state2.assertreleasecalled(True)
-                state2.assertpostreleasecalled(True)
+                state2.assertpostreleasecalled(False)
                 state2.assertlockexists(True)
 
                 state1.resetacquirefn()
@@ -217,7 +217,7 @@ class testlock(unittest.TestCase):
 
             lock1.release()
             state1.assertreleasecalled(True)
-            state1.assertpostreleasecalled(True)
+            state1.assertpostreleasecalled(False)
             state1.assertlockexists(True)
 
         lock0.release()
@@ -245,7 +245,7 @@ class testlock(unittest.TestCase):
             # release the child lock
             childlock.release()
             childstate.assertreleasecalled(True)
-            childstate.assertpostreleasecalled(True)
+            childstate.assertpostreleasecalled(False)
             childstate.assertlockexists(True)
 
         parentlock.release()