Mercurial > hg-stable
changeset 26491:366d489295ca
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.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 05 Oct 2015 14:37:59 -0700 |
parents | f0d730efb02f |
children | 3a0bb61371c5 |
files | mercurial/scmutil.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)