[PATCH 2 of 2] localrepo: allow creating inherited locks

Siddharth Agarwal sid0 at fb.com
Fri Oct 2 15:12:38 CDT 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1443209292 25200
#      Fri Sep 25 12:28:12 2015 -0700
# Node ID 9b8d1fa002d28bbce5f9a23f6210bee326e457cb
# Parent  c939fb3119d7da3d9044c840f397110f5bf7178c
localrepo: allow creating inherited locks

This is part of a series that will allow locks to be inherited by subprocesses
in limited circumstances.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1211,10 +1211,15 @@ class localrepository(object):
                 continue
             ce.refresh()
 
-    def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc):
+    def _lock(self, vfs, lockname, wait, releasefn, acquirefn, desc,
+              parentenvvar=None):
+        parentlock = None
+        if parentenvvar is not None:
+            parentlock = os.environ.get(parentenvvar)
         try:
             l = lockmod.lock(vfs, lockname, 0, releasefn=releasefn,
-                             acquirefn=acquirefn, desc=desc)
+                             acquirefn=acquirefn, desc=desc,
+                             parentlock=parentlock)
         except error.LockHeld as inst:
             if not wait:
                 raise


More information about the Mercurial-devel mailing list