cmdutil: break import cycle
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 08 Aug 2015 00:47:19 -0700
changeset 25930 221491bbaf7e
parent 25929 289149111d46
child 25931 a0847285d207
cmdutil: break import cycle This was the easiest place to break the chain, as there were only 2 uses of the imported module in the file.
mercurial/cmdutil.py
tests/test-module-imports.t
--- a/mercurial/cmdutil.py	Sun Jul 05 12:50:09 2015 +0900
+++ b/mercurial/cmdutil.py	Sat Aug 08 00:47:19 2015 -0700
@@ -10,7 +10,7 @@
 import os, sys, errno, re, tempfile, cStringIO, shutil
 import util, scmutil, templater, patch, error, templatekw, revlog, copies
 import match as matchmod
-import context, repair, graphmod, revset, phases, obsolete, pathutil
+import repair, graphmod, revset, phases, obsolete, pathutil
 import changelog
 import bookmarks
 import encoding
@@ -848,6 +848,8 @@
     :updatefunc: a function that update a repo to a given node
                  updatefunc(<repo>, <node>)
     """
+    # avoid cycle context -> subrepo -> cmdutil
+    import context
     tmpname, message, user, date, branch, nodeid, p1, p2 = \
         patch.extract(ui, hunk)
 
@@ -2464,6 +2466,9 @@
     return commitfunc(ui, repo, message, matcher, opts)
 
 def amend(ui, repo, commitfunc, old, extra, pats, opts):
+    # avoid cycle context -> subrepo -> cmdutil
+    import context
+
     # amend will reuse the existing user if not specified, but the obsolete
     # marker creation requires that the current user's name is specified.
     if obsolete.isenabled(repo, obsolete.createmarkersopt):
--- a/tests/test-module-imports.t	Sun Jul 05 12:50:09 2015 +0900
+++ b/tests/test-module-imports.t	Sat Aug 08 00:47:19 2015 -0700
@@ -127,7 +127,6 @@
   mercurial/ui.py mixed imports
      stdlib:    formatter
      relative:  config, error, progress, scmutil, util
-  Import cycle: mercurial.cmdutil -> mercurial.context -> mercurial.subrepo -> mercurial.cmdutil
   Import cycle: hgext.largefiles.basestore -> hgext.largefiles.localstore -> hgext.largefiles.basestore
   Import cycle: mercurial.commands -> mercurial.commandserver -> mercurial.dispatch -> mercurial.commands
   [1]