changeset 27504:ce3ae9ccd800

byterange: use absolute_import There were a lot of imports scattered around this file. They have been consolidated at the top of the file where they belong.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 21 Dec 2015 21:42:14 -0800
parents 0f4596622273
children 071af8d385a9
files mercurial/byterange.py tests/test-check-py3-compat.t
diffstat 2 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/byterange.py	Mon Dec 21 21:38:53 2015 -0800
+++ b/mercurial/byterange.py	Mon Dec 21 21:42:14 2015 -0800
@@ -17,11 +17,25 @@
 
 # $Id: byterange.py,v 1.9 2005/02/14 21:55:07 mstenner Exp $
 
+from __future__ import absolute_import
+
+import email
+import ftplib
+import mimetypes
 import os
+import re
+import socket
 import stat
 import urllib
 import urllib2
-import email.Utils
+
+addclosehook = urllib.addclosehook
+addinfourl = urllib.addinfourl
+splitattr = urllib.splitattr
+splitpasswd = urllib.splitpasswd
+splitport = urllib.splitport
+splituser = urllib.splituser
+unquote = urllib.unquote
 
 class RangeError(IOError):
     """Error raised when an unsatisfiable range is requested."""
@@ -196,8 +210,6 @@
     server would.
     """
     def open_local_file(self, req):
-        import mimetypes
-        import email
         host = req.get_host()
         file = req.get_selector()
         localfile = urllib.url2pathname(file)
@@ -234,13 +246,6 @@
 # follows:
 # -- range support modifications start/end here
 
-from urllib import splitport, splituser, splitpasswd, splitattr, \
-                   unquote, addclosehook, addinfourl
-import ftplib
-import socket
-import mimetypes
-import email
-
 class FTPRangeHandler(urllib2.FTPHandler):
     def ftp_open(self, req):
         host = req.get_host()
@@ -406,7 +411,6 @@
     if range_header is None:
         return None
     if _rangere is None:
-        import re
         _rangere = re.compile(r'^bytes=(\d{1,})-(\d*)')
     match = _rangere.match(range_header)
     if match:
--- a/tests/test-check-py3-compat.t	Mon Dec 21 21:38:53 2015 -0800
+++ b/tests/test-check-py3-compat.t	Mon Dec 21 21:42:14 2015 -0800
@@ -98,7 +98,6 @@
   hgext/zeroconf/__init__.py not using absolute_import
   i18n/check-translation.py not using absolute_import
   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