mercurial/scmutil.py
changeset 26490 f0d730efb02f
parent 26433 3ad41638b4b4
child 26491 366d489295ca
--- a/mercurial/scmutil.py	Mon Oct 05 14:27:37 2015 -0700
+++ b/mercurial/scmutil.py	Mon Oct 05 14:34:52 2015 -0700
@@ -1148,3 +1148,13 @@
             del obj.__dict__[self.name]
         except KeyError:
             raise AttributeError(self.name)
+
+def _locksub(repo, lock, envvar, cmd, environ=None, *args, **kwargs):
+    if lock is None:
+        raise error.LockInheritanceContractViolation(
+            'lock can only be inherited while held')
+    if environ is None:
+        environ = {}
+    with lock.inherit() as locker:
+        environ[envvar] = locker
+        return repo.ui.system(cmd, environ=environ, *args, **kwargs)