Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 26490:f0d730efb02f
scmutil: add a way for a subprocess to be run with an inheritable lock
This is part of a series that will allow locks to be inherited by subprocesses
in limited circumstances.
In an upcoming patch, we'll add an API for the wlock to be inherited.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 05 Oct 2015 14:34:52 -0700 |
parents | 3ad41638b4b4 |
children | 366d489295ca |
comparison
equal
deleted
inserted
replaced
26489:2a3fc0272e3f | 26490:f0d730efb02f |
---|---|
1146 def __delete__(self, obj): | 1146 def __delete__(self, obj): |
1147 try: | 1147 try: |
1148 del obj.__dict__[self.name] | 1148 del obj.__dict__[self.name] |
1149 except KeyError: | 1149 except KeyError: |
1150 raise AttributeError(self.name) | 1150 raise AttributeError(self.name) |
1151 | |
1152 def _locksub(repo, lock, envvar, cmd, environ=None, *args, **kwargs): | |
1153 if lock is None: | |
1154 raise error.LockInheritanceContractViolation( | |
1155 'lock can only be inherited while held') | |
1156 if environ is None: | |
1157 environ = {} | |
1158 with lock.inherit() as locker: | |
1159 environ[envvar] = locker | |
1160 return repo.ui.system(cmd, environ=environ, *args, **kwargs) |