py3: conditionalize httplib import
The httplib library is renamed to http.client in python 3. So the
import is conditionalized and a test is added in check-code to warn
to use util.httplib
--- a/contrib/check-code.py Wed Jun 29 19:43:27 2016 -0700
+++ b/contrib/check-code.py Tue Jun 28 16:01:53 2016 +0530
@@ -330,6 +330,7 @@
(r'^import xmlrpclib', "don't use xmlrpclib, use util.xmlrpclib"),
(r'^import cPickle', "don't use cPickle, use util.pickle"),
(r'^import pickle', "don't use pickle, use util.pickle"),
+ (r'^import httplib', "don't use httplib, use util.httplib"),
(r'\.next\(\)', "don't use .next(), use next(...)"),
# rules depending on implementation of repquote()
--- a/mercurial/httppeer.py Wed Jun 29 19:43:27 2016 -0700
+++ b/mercurial/httppeer.py Tue Jun 28 16:01:53 2016 +0530
@@ -9,7 +9,6 @@
from __future__ import absolute_import
import errno
-import httplib
import os
import socket
import tempfile
@@ -27,6 +26,7 @@
wireproto,
)
+httplib = util.httplib
urlerr = util.urlerr
urlreq = util.urlreq
--- a/mercurial/keepalive.py Wed Jun 29 19:43:27 2016 -0700
+++ b/mercurial/keepalive.py Tue Jun 28 16:01:53 2016 +0530
@@ -111,7 +111,6 @@
import errno
import hashlib
-import httplib
import socket
import sys
import thread
@@ -120,6 +119,7 @@
util,
)
+httplib = util.httplib
urlerr = util.urlerr
urlreq = util.urlreq
--- a/mercurial/pycompat.py Wed Jun 29 19:43:27 2016 -0700
+++ b/mercurial/pycompat.py Tue Jun 28 16:01:53 2016 +0530
@@ -18,6 +18,13 @@
pickle.dumps # silence pyflakes
try:
+ import httplib
+ httplib.HTTPException
+except ImportError:
+ import http.client as httplib
+ httplib.HTTPException
+
+try:
import SocketServer as socketserver
socketserver.ThreadingMixIn
except ImportError:
--- a/mercurial/url.py Wed Jun 29 19:43:27 2016 -0700
+++ b/mercurial/url.py Tue Jun 28 16:01:53 2016 +0530
@@ -10,7 +10,6 @@
from __future__ import absolute_import
import base64
-import httplib
import os
import socket
@@ -22,8 +21,9 @@
sslutil,
util,
)
+
+httplib = util.httplib
stringio = util.stringio
-
urlerr = util.urlerr
urlreq = util.urlreq
--- a/mercurial/util.py Wed Jun 29 19:43:27 2016 -0700
+++ b/mercurial/util.py Tue Jun 28 16:01:53 2016 +0530
@@ -47,6 +47,7 @@
for attr in (
'empty',
+ 'httplib',
'pickle',
'queue',
'urlerr',
--- a/tests/get-with-headers.py Wed Jun 29 19:43:27 2016 -0700
+++ b/tests/get-with-headers.py Tue Jun 28 16:01:53 2016 +0530
@@ -5,11 +5,16 @@
from __future__ import absolute_import, print_function
-import httplib
import json
import os
import sys
+from mercurial import (
+ util,
+)
+
+httplib = util.httplib
+
try:
import msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
--- a/tests/test-check-py3-compat.t Wed Jun 29 19:43:27 2016 -0700
+++ b/tests/test-check-py3-compat.t Tue Jun 28 16:01:53 2016 +0530
@@ -61,7 +61,7 @@
hgext/largefiles/lfutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
hgext/largefiles/localstore.py: error importing module: <SystemError> Parent module 'hgext.largefiles' not loaded, cannot perform relative import (line *) (glob)
hgext/largefiles/overrides.py: error importing module: <SyntaxError> invalid syntax (archival.py, line *) (line *) (glob)
- hgext/largefiles/proto.py: error importing: <ImportError> No module named 'httplib' (error at httppeer.py:*) (glob)
+ hgext/largefiles/proto.py: error importing: <SyntaxError> invalid syntax (bundle2.py, line *) (error at httppeer.py:*) (glob)
hgext/largefiles/remotestore.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at wireproto.py:*) (glob)
hgext/largefiles/reposetup.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
hgext/largefiles/storefactory.py: error importing: <SyntaxError> invalid syntax (bundle2.py, line *) (error at bundlerepo.py:*) (glob)
@@ -114,8 +114,8 @@
mercurial/hgweb/wsgicgi.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
mercurial/hook.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
mercurial/httpconnection.py: error importing: <ImportError> No module named 'rfc822' (error at __init__.py:*) (glob)
- mercurial/httppeer.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
- mercurial/keepalive.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
+ mercurial/httppeer.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line *) (line *) (glob)
+ mercurial/keepalive.py: error importing module: <ImportError> No module named 'thread' (line *) (glob)
mercurial/localrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
mercurial/mail.py: error importing module: <AttributeError> module 'email' has no attribute 'Header' (line *) (glob)
mercurial/manifest.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
@@ -141,7 +141,7 @@
mercurial/templater.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
mercurial/ui.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
mercurial/unionrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
- mercurial/url.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
+ mercurial/url.py: error importing: <ImportError> No module named 'rfc822' (error at __init__.py:*) (glob)
mercurial/verify.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
mercurial/win*.py: error importing module: <ImportError> No module named 'msvcrt' (line *) (glob)
mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line *) (glob)