merge: don't grab wlock when merging in memory
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 24 Jun 2020 23:17:56 -0700
changeset 44999 d1471dbbdd63
parent 44998 f2de8f31cb59
child 45000 3fadbdc47aed
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
mercurial/merge.py
--- a/mercurial/merge.py	Wed Jun 24 14:44:21 2020 +0200
+++ b/mercurial/merge.py	Wed Jun 24 23:17:56 2020 -0700
@@ -1572,7 +1572,11 @@
                     ),
                 )
             )
-    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()