lock: add a method to reacquire the lock after subprocesses exit
authorSiddharth Agarwal <sid0@fb.com>
Thu, 24 Sep 2015 16:00:41 -0700
changeset 26358 de5a52e5eb9e
parent 26357 6979a1369185
child 26359 c545d51c901e
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.
mercurial/lock.py
--- a/mercurial/lock.py	Thu Sep 24 10:37:13 2015 -0700
+++ b/mercurial/lock.py	Thu Sep 24 16:00:41 2015 -0700
@@ -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