scmutil: add a way for a repo's wlock to be inherited by a subprocess
authorSiddharth Agarwal <sid0@fb.com>
Mon, 05 Oct 2015 14:37:59 -0700
changeset 26491 366d489295ca
parent 26490 f0d730efb02f
child 26492 3a0bb61371c5
scmutil: add a way for a repo's wlock to be inherited by a subprocess This is part of a series that will allow locks to be inherited by subprocesses in limited circumstances. In the future, we'll call this for custom merge drivers.
mercurial/scmutil.py
--- a/mercurial/scmutil.py	Mon Oct 05 14:34:52 2015 -0700
+++ b/mercurial/scmutil.py	Mon Oct 05 14:37:59 2015 -0700
@@ -1158,3 +1158,12 @@
     with lock.inherit() as locker:
         environ[envvar] = locker
         return repo.ui.system(cmd, environ=environ, *args, **kwargs)
+
+def wlocksub(repo, cmd, *args, **kwargs):
+    """run cmd as a subprocess that allows inheriting repo's wlock
+
+    This can only be called while the wlock is held. This takes all the
+    arguments that ui.system does, and returns the exit code of the
+    subprocess."""
+    return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args,
+                    **kwargs)