# HG changeset patch # User Siddharth Agarwal # Date 1444081079 25200 # Node ID 366d489295ca7293887c4b9079620d8421616002 # Parent f0d730efb02f2476f1cd1127a3f0a56107097b96 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. diff -r f0d730efb02f -r 366d489295ca 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)