# HG changeset patch # User Martin von Zweigbergk # Date 2020-06-25 06:17:56 # Node ID d1471dbbdd63e17514ebcd8dd94cbbdc401fff61 # Parent f2de8f31cb597e67ff062d2e18b3f7792cfb2501 merge: don't grab wlock when merging in memory I noticed this because we have an internal extension that does an in-memory rebase while holding only a repo lock, which resulted in a developer warning about the working copy lock being taken after the repo lock. Differential Revision: https://phab.mercurial-scm.org/D8665 diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1572,7 +1572,11 @@ def update( ), ) ) - with repo.wlock(): + if wc is not None and wc.isinmemory(): + maybe_wlock = util.nullcontextmanager() + else: + maybe_wlock = repo.wlock() + with maybe_wlock: if wc is None: wc = repo[None] pl = wc.parents()