Mercurial > public > mercurial-scm > hg-stable
diff mercurial/lock.py @ 26498:e8564e04382d
lock: add a way to prevent locks from being inherited
We want to prevent locks from being inherited sometimes (e.g. when there's a
currently running transaction, which will break a lot of assumptions we're
making in here.)
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 06 Oct 2015 13:13:31 -0700 |
parents | 431094a3b21f |
children | 054abf2377e8 |
line wrap: on
line diff
--- a/mercurial/lock.py Tue Oct 06 15:55:50 2015 -0700 +++ b/mercurial/lock.py Tue Oct 06 13:13:31 2015 -0700 @@ -40,7 +40,7 @@ _host = None def __init__(self, vfs, file, timeout=-1, releasefn=None, acquirefn=None, - desc=None, parentlock=None): + desc=None, inheritchecker=None, parentlock=None): self.vfs = vfs self.f = file self.held = 0 @@ -48,6 +48,7 @@ self.releasefn = releasefn self.acquirefn = acquirefn self.desc = desc + self._inheritchecker = inheritchecker self.parentlock = parentlock self._parentheld = False self._inherited = False @@ -186,6 +187,8 @@ if self._inherited: raise error.LockInheritanceContractViolation( 'inherit cannot be called while lock is already inherited') + if self._inheritchecker is not None: + self._inheritchecker() if self.releasefn: self.releasefn() if self._parentheld: