Patchwork [7,of,7] keepalive: use absolute_import

login
register
mail settings
Submitter Gregory Szorc
Date Dec. 23, 2015, 12:31 a.m.
Message ID <38205e53b42d1f4683be.1450830710@7.1.168.192.in-addr.arpa>
Download mbox | patch
Permalink /patch/12259/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Gregory Szorc - Dec. 23, 2015, 12:31 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1450830508 28800
#      Tue Dec 22 16:28:28 2015 -0800
# Node ID 38205e53b42d1f4683be006a9e21d216d3d3a4db
# Parent  f2db4a1eb4b27117adf38e00fbd8f1d82ab53f8c
keepalive: use absolute_import
Yuya Nishihara - Dec. 23, 2015, 10:41 a.m.
On Tue, 22 Dec 2015 16:31:50 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1450830508 28800
> #      Tue Dec 22 16:28:28 2015 -0800
> # Node ID 38205e53b42d1f4683be006a9e21d216d3d3a4db
> # Parent  f2db4a1eb4b27117adf38e00fbd8f1d82ab53f8c
> keepalive: use absolute_import

Pushed the series to the clowncopter, thanks.

>  def continuity(url):
> -    from util import md5
> +    from . import util
> +    md5 = util.md5

OT: I'm not sure why it had to import md5 here.

Patch

diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -106,17 +106,19 @@  EXTRA ATTRIBUTES AND METHODS
 """
 
 # $Id: keepalive.py,v 1.14 2006/04/04 21:00:32 mstenner Exp $
 
+from __future__ import absolute_import
+
 import errno
 import httplib
 import socket
+import sys
 import thread
 import urllib2
 
 DEBUG = None
 
-import sys
 if sys.version_info < (2, 4):
     HANDLE_ERRORS = 1
 else: HANDLE_ERRORS = 0
 
@@ -615,9 +617,10 @@  def error_handler(url):
     print "open connections:", hosts
     keepalive_handler.close_all()
 
 def continuity(url):
-    from util import md5
+    from . import util
+    md5 = util.md5
     format = '%25s: %s'
 
     # first fetch the file with the normal http handler
     opener = urllib2.build_opener()
@@ -740,9 +743,8 @@  def test(url, N=10):
     test_timeout(url)
 
 if __name__ == '__main__':
     import time
-    import sys
     try:
         N = int(sys.argv[1])
         url = sys.argv[2]
     except (IndexError, ValueError):
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
@@ -105,9 +105,8 @@ 
   mercurial/httpclient/__init__.py not using absolute_import
   mercurial/httpclient/_readers.py not using absolute_import
   mercurial/httpclient/socketutil.py not using absolute_import
   mercurial/httpconnection.py not using absolute_import
-  mercurial/keepalive.py not using absolute_import
   mercurial/keepalive.py requires print_function
   mercurial/localrepo.py not using absolute_import
   mercurial/lsprof.py requires print_function
   mercurial/lsprofcalltree.py requires print_function