Skip to content
Snippets Groups Projects
Commit 57f1dbc9 authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

afterlock: add the callback to the top level lock (issue4608)

If 'wlock' is taken, we should add 'afterlock' callback to the 'wlock' instead.
Otherwise, running post transaction hook after 'lock' is release but 'wlock' is
still taken lead to a deadlock (eg: 'hg update' during a hook).

This situation is much more common since: 5dc5cd7abbf5

  push: acquire local 'wlock' if "pushback" is expected (BC) (issue4596)
parent 6a6b69d9
No related branches found
No related tags found
No related merge requests found
......@@ -1194,5 +1194,5 @@
return l
def _afterlock(self, callback):
"""add a callback to the current repository lock.
"""add a callback to be run when the repository is fully unlocked
......@@ -1198,9 +1198,12 @@
The callback will be executed on lock release."""
l = self._lockref and self._lockref()
if l:
l.postrelease.append(callback)
else:
The callback will be executed when the outermost lock is released
(with wlock being higher level than 'lock')."""
for ref in (self._wlockref, self._lockref):
l = ref and ref()
if l and l.held:
l.postrelease.append(callback)
break
else: # no lock have been found.
callback()
def lock(self, wait=True):
......
commit hooks can see env vars
(and post-transaction one are run unlocked)
$ hg init a
$ cd a
......@@ -16,6 +17,7 @@
> pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose"
> txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose"
> txnabort = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
> txnclose.checklock = hg debuglock > /dev/null
> EOF
$ echo a > a
$ hg add a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment