merge: cut import cycle at merge -> extensions
authorYuya Nishihara <yuya@tcha.org>
Tue, 06 Feb 2018 22:55:02 +0900
changeset 36010 46a54de96a54
parent 36009 55e8efa2451a
child 36011 c02200b11c39
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.
mercurial/cmdutil.py
mercurial/merge.py
--- a/mercurial/cmdutil.py	Tue Feb 06 22:36:38 2018 +0900
+++ b/mercurial/cmdutil.py	Tue Feb 06 22:55:02 2018 +0900
@@ -31,6 +31,7 @@
     formatter,
     logcmdutil,
     match as matchmod,
+    merge as mergemod,
     obsolete,
     patch,
     pathutil,
@@ -220,7 +221,6 @@
 
 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 @@
     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
--- a/mercurial/merge.py	Tue Feb 06 22:36:38 2018 +0900
+++ b/mercurial/merge.py	Tue Feb 06 22:55:02 2018 +0900
@@ -25,7 +25,6 @@
 from . import (
     copies,
     error,
-    extensions,
     filemerge,
     match as matchmod,
     obsutil,
@@ -1992,6 +1991,8 @@
         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