Patchwork D12217: merge: remove direct rustmod reference

login
register
mail settings
Submitter phabricator
Date March 1, 2022, 9:42 a.m.
Message ID <differential-rev-PHID-DREV-c5agwmocchnxkyuvgwec-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50557/
State New
Headers show

Comments

phabricator - March 1, 2022, 9:42 a.m.
Alphare created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  We shouldn't rely on this member being present in `dirstate.py`, this creates
  unnecessary coupling.
  This also can trigger certain issues in edge-cases where the policy is changed
  at runtime or multiple Python environments fight, which is an added bonus.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS




To: Alphare, #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
@@ -25,6 +25,7 @@ 
     mergestate as mergestatemod,
     obsutil,
     pathutil,
+    policy,
     pycompat,
     scmutil,
     subrepoutil,
@@ -1764,9 +1765,9 @@ 
         b'fsmonitor', b'warn_update_file_count'
     )
     # avoid cycle dirstate -> sparse -> merge -> dirstate
-    from . import dirstate
+    dirstate_rustmod = policy.importrust("dirstate")
 
-    if dirstate.rustmod is not None:
+    if dirstate_rustmod is not None:
         # When using rust status, fsmonitor becomes necessary at higher sizes
         fsmonitorthreshold = repo.ui.configint(
             b'fsmonitor',