[PATCH 4 of 5] commands: use absolute_import

Gregory Szorc gregory.szorc at gmail.com
Sat Jan 2 13:30:53 CST 2016


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1450765591 28800
#      Mon Dec 21 22:26:31 2015 -0800
# Node ID f77ea53bf73191d7fa373dddb0fbd03f3cb61b12
# Parent  6e6d6908446300b3ffe26dae645d59c8a8ac53c0
commands: use absolute_import

All mercurial.* modules are now using absolute_import \o/

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1,35 +1,85 @@
 # commands.py - command processing for mercurial
 #
 # Copyright 2005-2007 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 node import hex, bin, nullhex, nullid, nullrev, short
-from lock import release
-from i18n import _
-import os, re, difflib, time, tempfile, errno, shlex
-import sys, socket
-import hg, scmutil, util, revlog, copies, error, bookmarks
-import patch, help, encoding, templatekw, discovery
-import archival, changegroup, cmdutil, hbisect
-import sshserver, hgweb
-import extensions
-import merge as mergemod
-import minirst, revset, fileset
-import dagparser, context, simplemerge, graphmod, copies
-import random, operator
-import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil
-import phases, obsolete, exchange, bundle2, repair, lock as lockmod
-import ui as uimod
-import streamclone
-import commandserver
-import registrar
+from __future__ import absolute_import
+
+import difflib
+import errno
+import operator
+import os
+import random
+import re
+import shlex
+import socket
+import sys
+import tempfile
+import time
+
+from .i18n import _
+from .node import (
+    bin,
+    hex,
+    nullhex,
+    nullid,
+    nullrev,
+    short,
+)
+from . import (
+    archival,
+    bookmarks,
+    bundle2,
+    changegroup,
+    cmdutil,
+    commandserver,
+    context,
+    copies,
+    dagparser,
+    dagutil,
+    destutil,
+    discovery,
+    encoding,
+    error,
+    exchange,
+    extensions,
+    fileset,
+    graphmod,
+    hbisect,
+    help,
+    hg,
+    hgweb,
+    localrepo,
+    lock as lockmod,
+    merge as mergemod,
+    minirst,
+    obsolete,
+    patch,
+    phases,
+    pvec,
+    registrar,
+    repair,
+    revlog,
+    revset,
+    scmutil,
+    setdiscovery,
+    simplemerge,
+    sshserver,
+    streamclone,
+    templatekw,
+    treediscovery,
+    ui as uimod,
+    util,
+)
+
+release = lockmod.release
 
 table = {}
 
 command = cmdutil.command(table)
 
 # label constants
 # until 3.5, bookmarks.current was the advertised name, not
 # bookmarks.active, so we must use both to avoid breaking old
@@ -2636,26 +2686,31 @@ def debuginstall(ui):
               % ("%s.%s.%s" % sys.version_info[:3]))
     ui.status(_("checking Python lib (%s)...\n")
               % os.path.dirname(os.__file__))
 
     # compiled modules
     ui.status(_("checking installed modules (%s)...\n")
               % os.path.dirname(__file__))
     try:
-        import bdiff, mpatch, base85, osutil
+        from . import (
+            base85,
+            bdiff,
+            mpatch,
+            osutil,
+        )
         dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
     except Exception as inst:
         ui.write(" %s\n" % inst)
         ui.write(_(" One or more extensions could not be found"))
         ui.write(_(" (check that you compiled the extensions)\n"))
         problems += 1
 
     # templates
-    import templater
+    from . import templater
     p = templater.templatepaths()
     ui.status(_("checking templates (%s)...\n") % ' '.join(p))
     if p:
         m = templater.templatepath("map-cmdline.default")
         if m:
             # template found, check if it is working
             try:
                 templater.templater(m)
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
@@ -93,17 +93,16 @@
   hgext/transplant.py not using absolute_import
   hgext/win32mbcs.py not using absolute_import
   hgext/win32text.py not using absolute_import
   hgext/zeroconf/Zeroconf.py not using absolute_import
   hgext/zeroconf/Zeroconf.py requires print_function
   hgext/zeroconf/__init__.py not using absolute_import
   i18n/check-translation.py not using absolute_import
   i18n/polib.py not using absolute_import
-  mercurial/commands.py not using absolute_import
   mercurial/dispatch.py requires print_function
   mercurial/keepalive.py requires print_function
   mercurial/lsprof.py requires print_function
   mercurial/lsprofcalltree.py requires print_function
   mercurial/mail.py requires print_function
   setup.py not using absolute_import
   tests/filterpyflakes.py requires print_function
   tests/generate-working-copy-states.py requires print_function


More information about the Mercurial-devel mailing list