Patchwork [2,of,2] localrepo: allow creating inherited locks

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 2, 2015, 8:12 p.m.
Message ID <9b8d1fa002d28bbce5f9.1443816758@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10739/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 2, 2015, 8:12 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.
Pierre-Yves David - Oct. 2, 2015, 10:25 p.m.
On 10/02/2015 01:12 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@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.

This two seems fine and have been pushed. Can we get some documentation 
about what this parentenvvar is supposed to be written down here?

Patch

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