changeset 27358:ac839ee45b6a

util: use absolute_import
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 12 Dec 2015 23:14:08 -0800
parents 7f5a0bd4c9aa
children a56c47ed3885
files mercurial/util.py tests/test-check-py3-compat.t
diffstat 2 files changed, 33 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Sat Dec 12 23:30:37 2015 -0500
+++ b/mercurial/util.py	Sat Dec 12 23:14:08 2015 -0800
@@ -13,26 +13,47 @@
 hide platform-specific details from the core.
 """
 
-import i18n
-_ = i18n._
-import error, osutil, encoding, parsers
-import errno, shutil, sys, tempfile, traceback
+from __future__ import absolute_import
+
+import bz2
+import calendar
+import collections
+import datetime
+import errno
+import gc
+import hashlib
+import imp
+import os
 import re as remod
-import os, time, datetime, calendar, textwrap, signal, collections
-import imp, socket, urllib
-import gc
-import bz2
+import shutil
+import signal
+import socket
+import subprocess
+import sys
+import tempfile
+import textwrap
+import time
+import traceback
+import urllib
 import zlib
-import hashlib
+
+from . import (
+    encoding,
+    error,
+    i18n,
+    osutil,
+    parsers,
+)
 
 if os.name == 'nt':
-    import windows as platform
+    from . import windows as platform
 else:
-    import posix as platform
+    from . import posix as platform
 
 md5 = hashlib.md5
 sha1 = hashlib.sha1
 sha512 = hashlib.sha512
+_ = i18n._
 
 cachestat = platform.cachestat
 checkexec = platform.checkexec
@@ -200,7 +221,6 @@
         def buffer(sliceable, offset=0):
             return memoryview(sliceable)[offset:]
 
-import subprocess
 closefds = os.name == 'posix'
 
 _chunksize = 4096
@@ -326,7 +346,7 @@
 def version():
     """Return version information if available."""
     try:
-        import __version__
+        from . import __version__
         return __version__.version
     except ImportError:
         return 'unknown'
--- a/tests/test-check-py3-compat.t	Sat Dec 12 23:30:37 2015 -0500
+++ b/tests/test-check-py3-compat.t	Sat Dec 12 23:14:08 2015 -0800
@@ -128,7 +128,6 @@
   mercurial/scmwindows.py not using absolute_import
   mercurial/similar.py not using absolute_import
   mercurial/store.py not using absolute_import
-  mercurial/util.py not using absolute_import
   mercurial/windows.py not using absolute_import
   setup.py not using absolute_import
   tests/filterpyflakes.py requires print_function