changeset 28322:ebd0e86bdf89

cmdutil: use absolute_import Now that @command doesn't write back into commands when it is being executed during the loading of commands.py itself, we are unblocked from converting cmdutil to absolute_import.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 27 Feb 2016 23:57:07 -0800
parents a7b453b47726
children ffc693f87148
files mercurial/cmdutil.py tests/test-check-py3-compat.t
diffstat 2 files changed, 44 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Mar 01 10:33:06 2016 +0000
+++ b/mercurial/cmdutil.py	Sat Feb 27 23:57:07 2016 -0800
@@ -5,18 +5,47 @@
 # 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, nullid, nullrev, short
-from i18n import _
-import os, sys, errno, re, tempfile, cStringIO
-import util, scmutil, templater, patch, error, templatekw, revlog, copies
-import match as matchmod
-import repair, graphmod, revset, phases, obsolete, pathutil
-import changelog
-import bookmarks
-import encoding
-import formatter
-import crecord as crecordmod
-import lock as lockmod
+from __future__ import absolute_import
+
+import cStringIO
+import errno
+import os
+import re
+import sys
+import tempfile
+
+from .i18n import _
+from .node import (
+    bin,
+    hex,
+    nullid,
+    nullrev,
+    short,
+)
+
+from . import (
+    bookmarks,
+    changelog,
+    copies,
+    crecord as crecordmod,
+    encoding,
+    error,
+    formatter,
+    graphmod,
+    lock as lockmod,
+    match as matchmod,
+    obsolete,
+    patch,
+    pathutil,
+    phases,
+    repair,
+    revlog,
+    revset,
+    scmutil,
+    templatekw,
+    templater,
+    util,
+)
 
 def ishunk(x):
     hunkclasses = (crecordmod.uihunk, patch.recordhunk)
@@ -78,8 +107,7 @@
 
 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall,
             filterfn, *pats, **opts):
-    import merge as mergemod
-
+    from . import merge as mergemod
     if not ui.interactive():
         if cmdsuggest:
             msg = _('running non-interactively, use %s instead') % cmdsuggest
@@ -867,7 +895,7 @@
                  updatefunc(<repo>, <node>)
     """
     # avoid cycle context -> subrepo -> cmdutil
-    import context
+    from . import context
     extractdata = patch.extract(ui, hunk)
     tmpname = extractdata.get('filename')
     message = extractdata.get('message')
@@ -2507,7 +2535,7 @@
 
 def amend(ui, repo, commitfunc, old, extra, pats, opts):
     # avoid cycle context -> subrepo -> cmdutil
-    import context
+    from . 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.
--- a/tests/test-check-py3-compat.t	Tue Mar 01 10:33:06 2016 +0000
+++ b/tests/test-check-py3-compat.t	Sat Feb 27 23:57:07 2016 -0800
@@ -86,7 +86,6 @@
   hgext/win32text.py not using absolute_import
   i18n/check-translation.py not using absolute_import
   i18n/polib.py not using absolute_import
-  mercurial/cmdutil.py not using absolute_import
   mercurial/commands.py not using absolute_import
   setup.py not using absolute_import
   tests/filterpyflakes.py requires print_function