merge: remove direct rustmod reference stable 6.1
authorRaphaël Gomès <rgomes@octobus.net>
Mon, 28 Feb 2022 18:34:23 +0100
branchstable
changeset 48805 d4486810a179
parent 48804 f0081a551f37
child 48806 f97778b53b66
merge: remove direct rustmod reference 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. Differential Revision: https://phab.mercurial-scm.org/D12217
mercurial/merge.py
--- a/mercurial/merge.py	Mon Feb 21 11:22:40 2022 +0100
+++ b/mercurial/merge.py	Mon Feb 28 18:34:23 2022 +0100
@@ -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',