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

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 8, 2018, 12:52 p.m.
Message ID <eff74664c80ae0795a20.1518094356@mimosa>
Download mbox | patch
Permalink /patch/27492/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 8, 2018, 12:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Augie Fackler - Feb. 11, 2018, 1:51 p.m.
On Thu, Feb 08, 2018 at 09:52:36PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

queued, thanks

Patch

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