Patchwork D8665: merge: don't grab wlock when merging in memory

login
register
mail settings
Submitter phabricator
Date June 25, 2020, 2:20 p.m.
Message ID <differential-rev-PHID-DREV-3fnsssmy7jmf4rtopyqc-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46569/
State Superseded
Headers show

Comments

phabricator - June 25, 2020, 2:20 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8665

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -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()