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.
--- 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)