# HG changeset patch # User Siddharth Agarwal # Date 1443135641 25200 # Node ID de5a52e5eb9e3c6bb9992953a95e8979f96a3ca5 # Parent 6979a136918598254dfb1c39bb268ae186a82751 lock: add a method to reacquire the lock after subprocesses exit This is part of a series that will allow locks to be inherited by subprocesses in limited circumstances. diff --git a/mercurial/lock.py b/mercurial/lock.py --- a/mercurial/lock.py +++ b/mercurial/lock.py @@ -180,6 +180,14 @@ self._inherited = True return lockname + def reacquire(self): + if not self._inherited: + raise error.LockInheritanceContractViolation( + 'reacquire can only be called after prepinherit') + if self.acquirefn: + self.acquirefn() + self._inherited = False + def release(self): """release the lock and execute callback function if any