mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
0498f87da1
Summary: This is for cases like: repo1 = hg.repository(path) repo2 = hg.repository(path) # same path with repo1.lock(): repo2.lock() # deadlock Previously it simply deadlocks with confusing message: waiting for lock held by process X # X is the current process With this change it will raise a ProgrammingError about deadlock. Reviewed By: DurhamG Differential Revision: D24214458 fbshipit-source-id: 57faddaed6d2f1d36fab067c2e1f63b3cda0a1fe
28 lines
696 B
Python
28 lines
696 B
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2.
|
|
|
|
from testutil.dott import feature, sh, testtmp # noqa: F401
|
|
|
|
|
|
feature.require(["no-windows"])
|
|
|
|
|
|
def test_nested_lock():
|
|
from edenscm.mercurial import hg, ui as uimod
|
|
|
|
ui = uimod.ui.load()
|
|
repo1 = hg.repository(ui, testtmp.TESTTMP, create=True)
|
|
repo2 = hg.repository(ui, testtmp.TESTTMP)
|
|
# repo2.lock() should detect deadlock.
|
|
try:
|
|
with repo1.lock(), repo2.lock(wait=False):
|
|
pass
|
|
except Exception as ex:
|
|
msg = str(ex)
|
|
assert "deadlock" in msg
|
|
|
|
|
|
test_nested_lock()
|