# HG changeset patch # User Siddharth Agarwal # Date 2015-09-25 19:28:12 # Node ID b50f5beadf3ee8f9e3339595cc4d3ec055666069 # Parent 024644b1900bf05692e9631ea9bcdddba592e05e 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