[PATCH 7 of 8] ui: use absolute import

Gregory Szorc gregory.szorc at gmail.com
Mon May 25 14:23:51 CDT 2015

# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1432580903 25200
#      Mon May 25 12:08:23 2015 -0700
# Node ID 8daa70ee538105207ece9a23be502aabd26d94e7
# Parent  e53b7f554302416e5de6eb45098d5c2f418eeb4d
ui: use absolute import

And with this change, test-module-imports.t no longer complains about
ambiguity with regards to mixed imports.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -4,12 +4,25 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
-from i18n import _
-import errno, getpass, os, socket, sys, tempfile, traceback
-import config, scmutil, util, error, formatter
-from node import hex
+from __future__ import absolute_import
+import errno
+import getpass
+import os
+import socket
+import sys
+import tempfile
+import traceback
+import mercurial.config as config
+import mercurial.error as error
+import mercurial.formatter as formatter
+from mercurial.i18n import _
+from mercurial.node import hex
+import mercurial.scmutil as scmutil
+import mercurial.util as util
 samplehgrcs = {
 """# example user config (see "hg help config" for more info)
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
@@ -16,10 +16,7 @@ here that we should still endeavor to fi
 hidden by deduplication algorithm in the cycle detector, so fixing
 these may expose other cycles.
   $ hg locate 'mercurial/**.py' 'hgext/**.py' | sed 's-\\-/-g' | python "$import_checker" -
-  mercurial/ui.py mixed imports
-     stdlib:    formatter
-     relative:  config, error, 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

More information about the Mercurial-devel mailing list