[PATCH 2 of 2] merge: cut import cycle at merge -> extensions

Yuya Nishihara yuya at tcha.org
Thu Feb 8 07:52:36 EST 2018


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1517925302 -32400
#      Tue Feb 06 22:55:02 2018 +0900
# Node ID eff74664c80ae0795a209c2f8264bf073ab912fd
# Parent  64230c22a92152b70f41dfa429184cad84ac8eac
merge: cut import cycle at merge -> extensions

This seems less bad because checking fsmonitor looks like a temporary hack,
and cmdutil -> mergemod should be a valid dependency.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -31,6 +31,7 @@ from . import (
     formatter,
     logcmdutil,
     match as matchmod,
+    merge as mergemod,
     obsolete,
     patch,
     pathutil,
@@ -220,7 +221,6 @@ def recordfilter(ui, originalhunks, oper
 
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
             filterfn, *pats, **opts):
-    from . import merge as mergemod
     opts = pycompat.byteskwargs(opts)
     if not ui.interactive():
         if cmdsuggest:
@@ -557,8 +557,6 @@ def _commentlines(raw):
     return '\n'.join(commentedlines) + '\n'
 
 def _conflictsmsg(repo):
-    # avoid merge cycle
-    from . import merge as mergemod
     mergestate = mergemod.mergestate.read(repo)
     if not mergestate.active():
         return
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -25,7 +25,6 @@ from .node import (
 from . import (
     copies,
     error,
-    extensions,
     filemerge,
     match as matchmod,
     obsutil,
@@ -1992,6 +1991,8 @@ def update(repo, node, branchmerge, forc
         fsmonitorthreshold = repo.ui.configint('fsmonitor',
                                                'warn_update_file_count')
         try:
+            # avoid cycle: extensions -> cmdutil -> merge
+            from . import extensions
             extensions.find('fsmonitor')
             fsmonitorenabled = repo.ui.config('fsmonitor', 'mode') != 'off'
             # We intentionally don't look at whether fsmonitor has disabled


More information about the Mercurial-devel mailing list