Mercurial > public > mercurial-scm > hg
diff tests/test-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 | e72b62b154b0 |
line wrap: on
line diff
--- a/tests/test-lock.py Tue Oct 06 15:55:50 2015 -0700 +++ b/tests/test-lock.py Tue Oct 06 13:13:31 2015 -0700 @@ -8,6 +8,7 @@ import unittest from mercurial import ( + error, lock, scmutil, ) @@ -250,5 +251,21 @@ parentlock.release() + def testinheritcheck(self): + d = tempfile.mkdtemp(dir=os.getcwd()) + state = teststate(self, d) + def check(): + raise error.LockInheritanceContractViolation('check failed') + lock = state.makelock(inheritchecker=check) + state.assertacquirecalled(True) + + def tryinherit(): + with lock.inherit() as lockname: + pass + + self.assertRaises(error.LockInheritanceContractViolation, tryinherit) + + lock.release() + if __name__ == '__main__': silenttestrunner.main(__name__)