[PATCH 1 of 8] help: use absolute_import

Gregory Szorc gregory.szorc at gmail.com
Tue Dec 22 06:00:36 UTC 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1450762407 28800
#      Mon Dec 21 21:33:27 2015 -0800
# Node ID a9d3c36324cf61e140121bbb1106672627454a18
# Parent  3dea4eae4eebac11741f0c1dc5dcd9c88d8f4554
help: use absolute_import

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -1,23 +1,42 @@
 # help.py - help data for mercurial
 #
 # Copyright 2006 Matt Mackall <mpm at selenic.com>
 #
 # 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 gettext, _
-import itertools, os, textwrap
-import error
-import extensions, revset, fileset, templatekw, templatefilters, filemerge
-import templater
-import encoding, util, minirst
-import cmdutil
-import hgweb.webcommands as webcommands
+from __future__ import absolute_import
+
+import itertools
+import os
+import textwrap
+
+from .i18n import (
+    _,
+    gettext,
+)
+from . import (
+    cmdutil,
+    encoding,
+    error,
+    extensions,
+    filemerge,
+    fileset,
+    minirst,
+    revset,
+    templatefilters,
+    templatekw,
+    templater,
+    util,
+)
+from .hgweb import (
+    webcommands,
+)
 
 _exclkeywords = [
     "(DEPRECATED)",
     "(EXPERIMENTAL)",
     # i18n: "(DEPRECATED)" is a keyword, must be translated consistently
     _("(DEPRECATED)"),
     # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently
     _("(EXPERIMENTAL)"),
@@ -106,17 +125,17 @@ def topicmatch(ui, kw):
                'extensioncommands': [],
                }
     for names, header, doc in helptable:
         # Old extensions may use a str as doc.
         if (sum(map(lowercontains, names))
             or lowercontains(header)
             or (callable(doc) and lowercontains(doc(ui)))):
             results['topics'].append((names[0], header))
-    import commands # avoid cycle
+    from . import commands # avoid cycle
     for cmd, entry in commands.table.iteritems():
         if len(entry) == 3:
             summary = entry[2]
         else:
             summary = ''
         # translate docs *before* searching there
         docs = _(getattr(entry[0], '__doc__', None)) or ''
         if kw in cmd or lowercontains(summary) or lowercontains(docs):
@@ -263,17 +282,17 @@ addtopicsymbols('hgweb', '.. webcommands
                 dedent=True)
 
 def help_(ui, name, unknowncmd=False, full=True, subtopic=None, **opts):
     '''
     Generate the help for 'name' as unformatted restructured text. If
     'name' is None, describe the commands available.
     '''
 
-    import commands # avoid cycle
+    from . import commands # avoid cycle
 
     def helpcmd(name, subtopic=None):
         try:
             aliases, entry = cmdutil.findcmd(name, commands.table,
                                              strict=unknowncmd)
         except error.AmbiguousCommand as inst:
             # py3k fix: except vars can't be used outside the scope of the
             # except block, nor can be used inside a lambda. python issue4617
diff --git a/tests/test-check-py3-compat.t b/tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t
+++ b/tests/test-check-py3-compat.t
@@ -100,17 +100,16 @@
   i18n/polib.py not using absolute_import
   mercurial/byterange.py not using absolute_import
   mercurial/cmdutil.py not using absolute_import
   mercurial/commands.py not using absolute_import
   mercurial/context.py not using absolute_import
   mercurial/dirstate.py not using absolute_import
   mercurial/dispatch.py requires print_function
   mercurial/exchange.py not using absolute_import
-  mercurial/help.py not using absolute_import
   mercurial/httpclient/__init__.py not using absolute_import
   mercurial/httpclient/_readers.py not using absolute_import
   mercurial/httpclient/socketutil.py not using absolute_import
   mercurial/httpconnection.py not using absolute_import
   mercurial/keepalive.py not using absolute_import
   mercurial/keepalive.py requires print_function
   mercurial/localrepo.py not using absolute_import
   mercurial/lsprof.py requires print_function


More information about the Mercurial-devel mailing list