# HG changeset patch # User Gregory Szorc # Date 2015-08-08 07:47:19 # Node ID 221491bbaf7e82e4453e17e086bfb44591b76f8a # Parent 289149111d46cf8d243e0290bf81949078032fd9 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -10,7 +10,7 @@ from i18n import _ 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 @@ def tryimportone(ui, repo, hunk, parents :updatefunc: a function that update a repo to a given node updatefunc(, ) """ + # avoid cycle context -> subrepo -> cmdutil + import context tmpname, message, user, date, branch, nodeid, p1, p2 = \ patch.extract(ui, hunk) @@ -2464,6 +2466,9 @@ def commit(ui, repo, commitfunc, pats, o 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): diff --git a/tests/test-module-imports.t b/tests/test-module-imports.t --- a/tests/test-module-imports.t +++ b/tests/test-module-imports.t @@ -127,7 +127,6 @@ these may expose other cycles. 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]