[PATCH 4 of 5] lock: add a method to reacquire the lock after subprocesses exit

Siddharth Agarwal sid0 at fb.com
Thu Sep 24 18:29:39 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1443135641 25200
#      Thu Sep 24 16:00:41 2015 -0700
# Node ID ba556998f3d950a16bd890a1d7f23ba8cdb6801c
# Parent  a5358efa5b11aa4fe97bd91951a68dcaa84e6d15
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 @@ class lock(object):
         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
 


More information about the Mercurial-devel mailing list