# HG changeset patch # User Gregory Szorc # Date 2015-12-22 05:42:14 # Node ID ce3ae9ccd800fb081c35fd098dd6b5abe53048ef # Parent 0f45966222732af28b58df8bee8ceae8a4275722 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. diff --git a/mercurial/byterange.py b/mercurial/byterange.py --- a/mercurial/byterange.py +++ b/mercurial/byterange.py @@ -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 @@ class FileRangeHandler(urllib2.FileHandl 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 @@ class FileRangeHandler(urllib2.FileHandl # 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 @@ def range_header_to_tuple(range_header): 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: 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 @@ -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