##// END OF EJS Templates
pycompat: switch to util.urlreq/util.urlerr for py3 compat
timeless -
r28883:032c4c2f default
parent child Browse files
Show More
@@ -194,7 +194,6 b' 3) Deny access to a file to anyone but u'
194 194 from __future__ import absolute_import
195 195
196 196 import getpass
197 import urllib
198 197
199 198 from mercurial.i18n import _
200 199 from mercurial import (
@@ -203,6 +202,8 b' from mercurial import ('
203 202 util,
204 203 )
205 204
205 urlreq = util.urlreq
206
206 207 # Note for extension authors: ONLY specify testedwith = 'internal' for
207 208 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
208 209 # be specifying the version(s) of Mercurial they are tested with, or
@@ -287,7 +288,7 b' def hook(ui, repo, hooktype, node=None, '
287 288 if source == 'serve' and 'url' in kwargs:
288 289 url = kwargs['url'].split(':')
289 290 if url[0] == 'remote' and url[1].startswith('http'):
290 user = urllib.unquote(url[3])
291 user = urlreq.unquote(url[3])
291 292
292 293 if user is None:
293 294 user = getpass.getuser()
@@ -8,8 +8,6 b' import os'
8 8 import re
9 9 import sys
10 10 import tempfile
11 import urllib
12 import urllib2
13 11 import xml.dom.minidom
14 12
15 13 from mercurial import (
@@ -25,6 +23,8 b' from . import common'
25 23
26 24 stringio = util.stringio
27 25 propertycache = util.propertycache
26 urlerr = util.urlerr
27 urlreq = util.urlreq
28 28
29 29 commandline = common.commandline
30 30 commit = common.commit
@@ -94,7 +94,7 b' def quote(s):'
94 94 # so we can extend it safely with new components. The "safe"
95 95 # characters were taken from the "svn_uri__char_validity" table in
96 96 # libsvn_subr/path.c.
97 return urllib.quote(s, "!$&'()*+,-./:=@_~")
97 return urlreq.quote(s, "!$&'()*+,-./:=@_~")
98 98
99 99 def geturl(path):
100 100 try:
@@ -233,10 +233,10 b' def filecheck(ui, path, proto):'
233 233 # for the svn-specific "not found" XML.
234 234 def httpcheck(ui, path, proto):
235 235 try:
236 opener = urllib2.build_opener()
236 opener = urlreq.buildopener()
237 237 rsp = opener.open('%s://%s/!svn/ver/0/.svn' % (proto, path))
238 238 data = rsp.read()
239 except urllib2.HTTPError as inst:
239 except urlerr.httperror as inst:
240 240 if inst.code != 404:
241 241 # Except for 404 we cannot know for sure this is not an svn repo
242 242 ui.warn(_('svn: cannot probe remote repository, assume it could '
@@ -245,7 +245,7 b' def httpcheck(ui, path, proto):'
245 245 return True
246 246 data = inst.fp.read()
247 247 except Exception:
248 # Could be urllib2.URLError if the URL is invalid or anything else.
248 # Could be urlerr.urlerror if the URL is invalid or anything else.
249 249 return False
250 250 return '<m:human-readable errcode="160013">' in data
251 251
@@ -260,7 +260,7 b' def issvnurl(ui, url):'
260 260 if (os.name == 'nt' and path[:1] == '/' and path[1:2].isalpha()
261 261 and path[2:6].lower() == '%3a/'):
262 262 path = path[:2] + ':/' + path[6:]
263 path = urllib.url2pathname(path)
263 path = urlreq.url2pathname(path)
264 264 except ValueError:
265 265 proto = 'file'
266 266 path = os.path.abspath(url)
@@ -330,7 +330,7 b' class svn_source(converter_source):'
330 330 self.baseurl = svn.ra.get_repos_root(self.ra)
331 331 # Module is either empty or a repository path starting with
332 332 # a slash and not ending with a slash.
333 self.module = urllib.unquote(self.url[len(self.baseurl):])
333 self.module = urlreq.unquote(self.url[len(self.baseurl):])
334 334 self.prevmodule = None
335 335 self.rootmodule = self.module
336 336 self.commits = {}
@@ -4,12 +4,14 b''
4 4 # GNU General Public License version 2 or any later version.
5 5
6 6 import os
7 import urllib2
8 7 import re
9 8
10 9 from mercurial import error, httppeer, util, wireproto
11 10 from mercurial.i18n import _
12 11
12 urlerr = util.urlerr
13 urlreq = util.urlreq
14
13 15 import lfutil
14 16
15 17 LARGEFILES_REQUIRED_MSG = ('\nThis repository uses the largefiles extension.'
@@ -140,7 +142,7 b' def wirereposetup(ui, repo):'
140 142 yield result, f
141 143 try:
142 144 yield int(f.value)
143 except (ValueError, urllib2.HTTPError):
145 except (ValueError, urlerr.httperror):
144 146 # If the server returns anything but an integer followed by a
145 147 # newline, newline, it's not speaking our language; if we get
146 148 # an HTTP error, we can't be sure the largefile is present;
@@ -6,11 +6,12 b''
6 6
7 7 '''remote largefile store; the base class for wirestore'''
8 8
9 import urllib2
10
11 9 from mercurial import util, wireproto, error
12 10 from mercurial.i18n import _
13 11
12 urlerr = util.urlerr
13 urlreq = util.urlreq
14
14 15 import lfutil
15 16 import basestore
16 17
@@ -49,11 +50,11 b' class remotestore(basestore.basestore):'
49 50 def _getfile(self, tmpfile, filename, hash):
50 51 try:
51 52 chunks = self._get(hash)
52 except urllib2.HTTPError as e:
53 except urlerr.httperror as e:
53 54 # 401s get converted to error.Aborts; everything else is fine being
54 55 # turned into a StoreError
55 56 raise basestore.StoreError(filename, hash, self.url, str(e))
56 except urllib2.URLError as e:
57 except urlerr.urlerror as e:
57 58 # This usually indicates a connection problem, so don't
58 59 # keep trying with the other files... they will probably
59 60 # all fail too.
@@ -152,7 +152,6 b' import re'
152 152 import string
153 153 import struct
154 154 import sys
155 import urllib
156 155
157 156 from .i18n import _
158 157 from . import (
@@ -165,6 +164,9 b' from . import ('
165 164 util,
166 165 )
167 166
167 urlerr = util.urlerr
168 urlreq = util.urlreq
169
168 170 _pack = struct.pack
169 171 _unpack = struct.unpack
170 172
@@ -457,8 +459,8 b' def decodecaps(blob):'
457 459 else:
458 460 key, vals = line.split('=', 1)
459 461 vals = vals.split(',')
460 key = urllib.unquote(key)
461 vals = [urllib.unquote(v) for v in vals]
462 key = urlreq.unquote(key)
463 vals = [urlreq.unquote(v) for v in vals]
462 464 caps[key] = vals
463 465 return caps
464 466
@@ -467,8 +469,8 b' def encodecaps(caps):'
467 469 chunks = []
468 470 for ca in sorted(caps):
469 471 vals = caps[ca]
470 ca = urllib.quote(ca)
471 vals = [urllib.quote(v) for v in vals]
472 ca = urlreq.quote(ca)
473 vals = [urlreq.quote(v) for v in vals]
472 474 if vals:
473 475 ca = "%s=%s" % (ca, ','.join(vals))
474 476 chunks.append(ca)
@@ -570,9 +572,9 b' class bundle20(object):'
570 572 """return a encoded version of all stream parameters"""
571 573 blocks = []
572 574 for par, value in self._params:
573 par = urllib.quote(par)
575 par = urlreq.quote(par)
574 576 if value is not None:
575 value = urllib.quote(value)
577 value = urlreq.quote(value)
576 578 par = '%s=%s' % (par, value)
577 579 blocks.append(par)
578 580 return ' '.join(blocks)
@@ -691,7 +693,7 b' class unbundle20(unpackermixin):'
691 693 params = {}
692 694 for p in paramsblock.split(' '):
693 695 p = p.split('=', 1)
694 p = [urllib.unquote(i) for i in p]
696 p = [urlreq.unquote(i) for i in p]
695 697 if len(p) < 2:
696 698 p.append(None)
697 699 self._processparam(*p)
@@ -1269,7 +1271,7 b' def bundle2caps(remote):'
1269 1271 raw = remote.capable('bundle2')
1270 1272 if not raw and raw != '':
1271 1273 return {}
1272 capsblob = urllib.unquote(remote.capable('bundle2'))
1274 capsblob = urlreq.unquote(remote.capable('bundle2'))
1273 1275 return decodecaps(capsblob)
1274 1276
1275 1277 def obsmarkersversion(caps):
@@ -26,22 +26,27 b' import os'
26 26 import re
27 27 import socket
28 28 import stat
29 import urllib
30 import urllib2
29
30 from . import (
31 util,
32 )
33
34 urlerr = util.urlerr
35 urlreq = util.urlreq
31 36
32 addclosehook = urllib.addclosehook
33 addinfourl = urllib.addinfourl
34 splitattr = urllib.splitattr
35 splitpasswd = urllib.splitpasswd
36 splitport = urllib.splitport
37 splituser = urllib.splituser
38 unquote = urllib.unquote
37 addclosehook = urlreq.addclosehook
38 addinfourl = urlreq.addinfourl
39 splitattr = urlreq.splitattr
40 splitpasswd = urlreq.splitpasswd
41 splitport = urlreq.splitport
42 splituser = urlreq.splituser
43 unquote = urlreq.unquote
39 44
40 45 class RangeError(IOError):
41 46 """Error raised when an unsatisfiable range is requested."""
42 47 pass
43 48
44 class HTTPRangeHandler(urllib2.BaseHandler):
49 class HTTPRangeHandler(urlreq.basehandler):
45 50 """Handler that enables HTTP Range headers.
46 51
47 52 This was extremely simple. The Range header is a HTTP feature to
@@ -54,20 +59,20 b' class HTTPRangeHandler(urllib2.BaseHandl'
54 59 import byterange
55 60
56 61 range_handler = range.HTTPRangeHandler()
57 opener = urllib2.build_opener(range_handler)
62 opener = urlreq.buildopener(range_handler)
58 63
59 64 # install it
60 urllib2.install_opener(opener)
65 urlreq.installopener(opener)
61 66
62 67 # create Request and set Range header
63 req = urllib2.Request('http://www.python.org/')
68 req = urlreq.request('http://www.python.org/')
64 69 req.header['Range'] = 'bytes=30-50'
65 f = urllib2.urlopen(req)
70 f = urlreq.urlopen(req)
66 71 """
67 72
68 73 def http_error_206(self, req, fp, code, msg, hdrs):
69 74 # 206 Partial Content Response
70 r = urllib.addinfourl(fp, hdrs, req.get_full_url())
75 r = urlreq.addinfourl(fp, hdrs, req.get_full_url())
71 76 r.code = code
72 77 r.msg = msg
73 78 return r
@@ -204,7 +209,7 b' class RangeableFileObject(object):'
204 209 raise RangeError('Requested Range Not Satisfiable')
205 210 pos += bufsize
206 211
207 class FileRangeHandler(urllib2.FileHandler):
212 class FileRangeHandler(urlreq.filehandler):
208 213 """FileHandler subclass that adds Range support.
209 214 This class handles Range headers exactly like an HTTP
210 215 server would.
@@ -212,15 +217,15 b' class FileRangeHandler(urllib2.FileHandl'
212 217 def open_local_file(self, req):
213 218 host = req.get_host()
214 219 file = req.get_selector()
215 localfile = urllib.url2pathname(file)
220 localfile = urlreq.url2pathname(file)
216 221 stats = os.stat(localfile)
217 222 size = stats[stat.ST_SIZE]
218 223 modified = email.Utils.formatdate(stats[stat.ST_MTIME])
219 224 mtype = mimetypes.guess_type(file)[0]
220 225 if host:
221 host, port = urllib.splitport(host)
226 host, port = urlreq.splitport(host)
222 227 if port or socket.gethostbyname(host) not in self.get_names():
223 raise urllib2.URLError('file not on local host')
228 raise urlerr.urlerror('file not on local host')
224 229 fo = open(localfile,'rb')
225 230 brange = req.headers.get('Range', None)
226 231 brange = range_header_to_tuple(brange)
@@ -236,7 +241,7 b' class FileRangeHandler(urllib2.FileHandl'
236 241 headers = email.message_from_string(
237 242 'Content-Type: %s\nContent-Length: %d\nLast-Modified: %s\n' %
238 243 (mtype or 'text/plain', size, modified))
239 return urllib.addinfourl(fo, headers, 'file:'+file)
244 return urlreq.addinfourl(fo, headers, 'file:'+file)
240 245
241 246
242 247 # FTP Range Support
@@ -246,7 +251,7 b' class FileRangeHandler(urllib2.FileHandl'
246 251 # follows:
247 252 # -- range support modifications start/end here
248 253
249 class FTPRangeHandler(urllib2.FTPHandler):
254 class FTPRangeHandler(urlreq.ftphandler):
250 255 def ftp_open(self, req):
251 256 host = req.get_host()
252 257 if not host:
@@ -270,7 +275,7 b' class FTPRangeHandler(urllib2.FTPHandler'
270 275 try:
271 276 host = socket.gethostbyname(host)
272 277 except socket.error as msg:
273 raise urllib2.URLError(msg)
278 raise urlerr.urlerror(msg)
274 279 path, attrs = splitattr(req.get_selector())
275 280 dirs = path.split('/')
276 281 dirs = map(unquote, dirs)
@@ -334,7 +339,7 b' class FTPRangeHandler(urllib2.FTPHandler'
334 339 fw = ftpwrapper(user, passwd, host, port, dirs)
335 340 return fw
336 341
337 class ftpwrapper(urllib.ftpwrapper):
342 class ftpwrapper(urlreq.ftpwrapper):
338 343 # range support note:
339 344 # this ftpwrapper code is copied directly from
340 345 # urllib. The only enhancement is to add the rest
@@ -8,8 +8,6 b''
8 8 from __future__ import absolute_import
9 9
10 10 import errno
11 import urllib
12 import urllib2
13 11
14 12 from .i18n import _
15 13 from .node import (
@@ -35,6 +33,9 b' from . import ('
35 33 util,
36 34 )
37 35
36 urlerr = util.urlerr
37 urlreq = util.urlreq
38
38 39 # Maps bundle compression human names to internal representation.
39 40 _bundlespeccompressions = {'none': None,
40 41 'bzip2': 'BZ',
@@ -97,8 +98,8 b' def parsebundlespec(repo, spec, strict=T'
97 98 'missing "=" in parameter: %s') % p)
98 99
99 100 key, value = p.split('=', 1)
100 key = urllib.unquote(key)
101 value = urllib.unquote(value)
101 key = urlreq.unquote(key)
102 value = urlreq.unquote(value)
102 103 params[key] = value
103 104
104 105 return version, params
@@ -236,7 +237,7 b' def getbundlespec(ui, fh):'
236 237 elif isinstance(b, streamclone.streamcloneapplier):
237 238 requirements = streamclone.readbundle1header(fh)[2]
238 239 params = 'requirements=%s' % ','.join(sorted(requirements))
239 return 'none-packed1;%s' % urllib.quote(params)
240 return 'none-packed1;%s' % urlreq.quote(params)
240 241 else:
241 242 raise error.Abort(_('unknown bundle type: %s') % b)
242 243
@@ -1465,7 +1466,7 b' def caps20to10(repo):'
1465 1466 """return a set with appropriate options to use bundle20 during getbundle"""
1466 1467 caps = set(['HG20'])
1467 1468 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
1468 caps.add('bundle2=' + urllib.quote(capsblob))
1469 caps.add('bundle2=' + urlreq.quote(capsblob))
1469 1470 return caps
1470 1471
1471 1472 # List of names of steps to perform for a bundle2 for getbundle, order matters.
@@ -1531,7 +1532,7 b' def getbundle(repo, source, heads=None, '
1531 1532 b2caps = {}
1532 1533 for bcaps in bundlecaps:
1533 1534 if bcaps.startswith('bundle2='):
1534 blob = urllib.unquote(bcaps[len('bundle2='):])
1535 blob = urlreq.unquote(bcaps[len('bundle2='):])
1535 1536 b2caps.update(bundle2.decodecaps(blob))
1536 1537 bundler = bundle2.bundle20(repo.ui, b2caps)
1537 1538
@@ -1800,8 +1801,8 b' def parseclonebundlesmanifest(repo, s):'
1800 1801 attrs = {'URL': fields[0]}
1801 1802 for rawattr in fields[1:]:
1802 1803 key, value = rawattr.split('=', 1)
1803 key = urllib.unquote(key)
1804 value = urllib.unquote(value)
1804 key = urlreq.unquote(key)
1805 value = urlreq.unquote(value)
1805 1806 attrs[key] = value
1806 1807
1807 1808 # Parse BUNDLESPEC into components. This makes client-side
@@ -1917,9 +1918,9 b' def trypullbundlefromurl(ui, repo, url):'
1917 1918 cg.apply(repo, 'clonebundles', url)
1918 1919 tr.close()
1919 1920 return True
1920 except urllib2.HTTPError as e:
1921 except urlerr.httperror as e:
1921 1922 ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
1922 except urllib2.URLError as e:
1923 except urlerr.urlerror as e:
1923 1924 ui.warn(_('error fetching bundle: %s\n') % e.reason[1])
1924 1925
1925 1926 return False
@@ -8,7 +8,6 b''
8 8 from __future__ import absolute_import
9 9
10 10 import cgi
11 import urllib
12 11 import zlib
13 12
14 13 from .common import (
@@ -21,6 +20,9 b' from .. import ('
21 20 )
22 21 stringio = util.stringio
23 22
23 urlerr = util.urlerr
24 urlreq = util.urlreq
25
24 26 HGTYPE = 'application/mercurial-0.1'
25 27 HGERRTYPE = 'application/hg-error'
26 28
@@ -82,8 +84,8 b' class webproto(wireproto.abstractserverp'
82 84 def _client(self):
83 85 return 'remote:%s:%s:%s' % (
84 86 self.req.env.get('wsgi.url_scheme') or 'http',
85 urllib.quote(self.req.env.get('REMOTE_HOST', '')),
86 urllib.quote(self.req.env.get('REMOTE_USER', '')))
87 urlreq.quote(self.req.env.get('REMOTE_HOST', '')),
88 urlreq.quote(self.req.env.get('REMOTE_USER', '')))
87 89
88 90 def iscmd(cmd):
89 91 return cmd in wireproto.commands
@@ -15,7 +15,6 b' import os'
15 15 import socket
16 16 import sys
17 17 import traceback
18 import urllib
19 18
20 19 from ..i18n import _
21 20
@@ -24,6 +23,9 b' from .. import ('
24 23 util,
25 24 )
26 25
26 urlerr = util.urlerr
27 urlreq = util.urlreq
28
27 29 from . import (
28 30 common,
29 31 )
@@ -38,7 +40,7 b' def _splitURI(uri):'
38 40 path, query = uri.split('?', 1)
39 41 else:
40 42 path, query = uri, ''
41 return urllib.unquote(path), query
43 return urlreq.unquote(path), query
42 44
43 45 class _error_logger(object):
44 46 def __init__(self, handler):
@@ -13,8 +13,6 b' from __future__ import absolute_import'
13 13 import logging
14 14 import os
15 15 import socket
16 import urllib
17 import urllib2
18 16
19 17 from .i18n import _
20 18 from . import (
@@ -23,6 +21,9 b' from . import ('
23 21 util,
24 22 )
25 23
24 urlerr = util.urlerr
25 urlreq = util.urlreq
26
26 27 # moved here from url.py to avoid a cycle
27 28 class httpsendfile(object):
28 29 """This is a wrapper around the objects returned by python's "open".
@@ -123,10 +124,10 b" LOGFMT = '%(levelname)s:%(name)s:%(linen"
123 124 # Subclass BOTH of these because otherwise urllib2 "helpfully"
124 125 # reinserts them since it notices we don't include any subclasses of
125 126 # them.
126 class http2handler(urllib2.HTTPHandler, urllib2.HTTPSHandler):
127 class http2handler(urlreq.httphandler, urlreq.httpshandler):
127 128 def __init__(self, ui, pwmgr):
128 129 global _configuredlogging
129 urllib2.AbstractHTTPHandler.__init__(self)
130 urlreq.abstracthttphandler.__init__(self)
130 131 self.ui = ui
131 132 self.pwmgr = pwmgr
132 133 self._connections = {}
@@ -187,7 +188,7 b' class http2handler(urllib2.HTTPHandler, '
187 188 proxy = None
188 189
189 190 if not host:
190 raise urllib2.URLError('no host given')
191 raise urlerr.urlerror('no host given')
191 192
192 193 connkey = use_ssl, host, proxy
193 194 allconns = self._connections.get(connkey, [])
@@ -217,13 +218,13 b' class http2handler(urllib2.HTTPHandler, '
217 218 h.request(req.get_method(), path, req.data, headers)
218 219 r = h.getresponse()
219 220 except socket.error as err: # XXX what error?
220 raise urllib2.URLError(err)
221 raise urlerr.urlerror(err)
221 222
222 223 # Pick apart the HTTPResponse object to get the addinfourl
223 224 # object initialized properly.
224 225 r.recv = r.read
225 226
226 resp = urllib.addinfourl(r, r.headers, req.get_full_url())
227 resp = urlreq.addinfourl(r, r.headers, req.get_full_url())
227 228 resp.code = r.status
228 229 resp.msg = r.reason
229 230 return resp
@@ -13,8 +13,6 b' import httplib'
13 13 import os
14 14 import socket
15 15 import tempfile
16 import urllib
17 import urllib2
18 16 import zlib
19 17
20 18 from .i18n import _
@@ -29,6 +27,9 b' from . import ('
29 27 wireproto,
30 28 )
31 29
30 urlerr = util.urlerr
31 urlreq = util.urlreq
32
32 33 def zgenerator(f):
33 34 zd = zlib.decompressobj()
34 35 try:
@@ -59,7 +60,7 b' class httppeer(wireproto.wirepeer):'
59 60 self.ui.debug('using %s\n' % self._url)
60 61
61 62 self.urlopener = url.opener(ui, authinfo)
62 self.requestbuilder = urllib2.Request
63 self.requestbuilder = urlreq.request
63 64
64 65 def __del__(self):
65 66 if self.urlopener:
@@ -105,7 +106,7 b' class httppeer(wireproto.wirepeer):'
105 106 # object rather than a basestring
106 107 canmungedata = not data or isinstance(data, basestring)
107 108 if postargsok and canmungedata:
108 strargs = urllib.urlencode(sorted(args.items()))
109 strargs = urlreq.urlencode(sorted(args.items()))
109 110 if strargs:
110 111 if not data:
111 112 data = strargs
@@ -119,7 +120,7 b' class httppeer(wireproto.wirepeer):'
119 120 headersize = int(httpheader.split(',', 1)[0])
120 121 if headersize > 0:
121 122 # The headers can typically carry more data than the URL.
122 encargs = urllib.urlencode(sorted(args.items()))
123 encargs = urlreq.urlencode(sorted(args.items()))
123 124 headerfmt = 'X-HgArg-%s'
124 125 contentlen = headersize - len(headerfmt % '000' + ': \r\n')
125 126 headernum = 0
@@ -132,7 +133,7 b' class httppeer(wireproto.wirepeer):'
132 133 headers['Vary'] = ','.join(varyheaders)
133 134 else:
134 135 q += sorted(args.items())
135 qs = '?%s' % urllib.urlencode(q)
136 qs = '?%s' % urlreq.urlencode(q)
136 137 cu = "%s%s" % (self._url, qs)
137 138 size = 0
138 139 if util.safehasattr(data, 'length'):
@@ -150,7 +151,7 b' class httppeer(wireproto.wirepeer):'
150 151 req.add_unredirected_header('Content-Length', '%d' % size)
151 152 try:
152 153 resp = self.urlopener.open(req)
153 except urllib2.HTTPError as inst:
154 except urlerr.httperror as inst:
154 155 if inst.code == 401:
155 156 raise error.Abort(_('authorization failed'))
156 157 raise
@@ -28,10 +28,10 b''
28 28 >>> import urllib2
29 29 >>> from keepalive import HTTPHandler
30 30 >>> keepalive_handler = HTTPHandler()
31 >>> opener = urllib2.build_opener(keepalive_handler)
32 >>> urllib2.install_opener(opener)
31 >>> opener = urlreq.buildopener(keepalive_handler)
32 >>> urlreq.installopener(opener)
33 33 >>>
34 >>> fo = urllib2.urlopen('http://www.python.org')
34 >>> fo = urlreq.urlopen('http://www.python.org')
35 35
36 36 If a connection to a given host is requested, and all of the existing
37 37 connections are still in use, another connection will be opened. If
@@ -114,7 +114,13 b' import httplib'
114 114 import socket
115 115 import sys
116 116 import thread
117 import urllib2
117
118 from . import (
119 util,
120 )
121
122 urlerr = util.urlerr
123 urlreq = util.urlreq
118 124
119 125 DEBUG = None
120 126
@@ -227,7 +233,7 b' class KeepAliveHandler(object):'
227 233 def do_open(self, http_class, req):
228 234 host = req.get_host()
229 235 if not host:
230 raise urllib2.URLError('no host given')
236 raise urlerr.urlerror('no host given')
231 237
232 238 try:
233 239 h = self._cm.get_ready_conn(host)
@@ -254,7 +260,7 b' class KeepAliveHandler(object):'
254 260 self._start_transaction(h, req)
255 261 r = h.getresponse()
256 262 except (socket.error, httplib.HTTPException) as err:
257 raise urllib2.URLError(err)
263 raise urlerr.urlerror(err)
258 264
259 265 # if not a persistent connection, don't try to reuse it
260 266 if r.will_close:
@@ -346,14 +352,14 b' class KeepAliveHandler(object):'
346 352 else:
347 353 h.putrequest('GET', req.get_selector(), **skipheaders)
348 354 except socket.error as err:
349 raise urllib2.URLError(err)
355 raise urlerr.urlerror(err)
350 356 for k, v in headers.items():
351 357 h.putheader(k, v)
352 358 h.endheaders()
353 359 if req.has_data():
354 360 h.send(data)
355 361
356 class HTTPHandler(KeepAliveHandler, urllib2.HTTPHandler):
362 class HTTPHandler(KeepAliveHandler, urlreq.httphandler):
357 363 pass
358 364
359 365 class HTTPResponse(httplib.HTTPResponse):
@@ -593,14 +599,14 b' def error_handler(url):'
593 599 global HANDLE_ERRORS
594 600 orig = HANDLE_ERRORS
595 601 keepalive_handler = HTTPHandler()
596 opener = urllib2.build_opener(keepalive_handler)
597 urllib2.install_opener(opener)
602 opener = urlreq.buildopener(keepalive_handler)
603 urlreq.installopener(opener)
598 604 pos = {0: 'off', 1: 'on'}
599 605 for i in (0, 1):
600 606 print(" fancy error handling %s (HANDLE_ERRORS = %i)" % (pos[i], i))
601 607 HANDLE_ERRORS = i
602 608 try:
603 fo = urllib2.urlopen(url)
609 fo = urlreq.urlopen(url)
604 610 fo.read()
605 611 fo.close()
606 612 try:
@@ -623,25 +629,25 b' def continuity(url):'
623 629 format = '%25s: %s'
624 630
625 631 # first fetch the file with the normal http handler
626 opener = urllib2.build_opener()
627 urllib2.install_opener(opener)
628 fo = urllib2.urlopen(url)
632 opener = urlreq.buildopener()
633 urlreq.installopener(opener)
634 fo = urlreq.urlopen(url)
629 635 foo = fo.read()
630 636 fo.close()
631 637 m = md5(foo)
632 638 print(format % ('normal urllib', m.hexdigest()))
633 639
634 640 # now install the keepalive handler and try again
635 opener = urllib2.build_opener(HTTPHandler())
636 urllib2.install_opener(opener)
641 opener = urlreq.buildopener(HTTPHandler())
642 urlreq.installopener(opener)
637 643
638 fo = urllib2.urlopen(url)
644 fo = urlreq.urlopen(url)
639 645 foo = fo.read()
640 646 fo.close()
641 647 m = md5(foo)
642 648 print(format % ('keepalive read', m.hexdigest()))
643 649
644 fo = urllib2.urlopen(url)
650 fo = urlreq.urlopen(url)
645 651 foo = ''
646 652 while True:
647 653 f = fo.readline()
@@ -657,15 +663,15 b' def comp(N, url):'
657 663
658 664 sys.stdout.write(' first using the normal urllib handlers')
659 665 # first use normal opener
660 opener = urllib2.build_opener()
661 urllib2.install_opener(opener)
666 opener = urlreq.buildopener()
667 urlreq.installopener(opener)
662 668 t1 = fetch(N, url)
663 669 print(' TIME: %.3f s' % t1)
664 670
665 671 sys.stdout.write(' now using the keepalive handler ')
666 672 # now install the keepalive handler and try again
667 opener = urllib2.build_opener(HTTPHandler())
668 urllib2.install_opener(opener)
673 opener = urlreq.buildopener(HTTPHandler())
674 urlreq.installopener(opener)
669 675 t2 = fetch(N, url)
670 676 print(' TIME: %.3f s' % t2)
671 677 print(' improvement factor: %.2f' % (t1 / t2))
@@ -677,7 +683,7 b' def fetch(N, url, delay=0):'
677 683 for i in range(N):
678 684 if delay and i > 0:
679 685 time.sleep(delay)
680 fo = urllib2.urlopen(url)
686 fo = urlreq.urlopen(url)
681 687 foo = fo.read()
682 688 fo.close()
683 689 lens.append(len(foo))
@@ -700,7 +706,7 b' def test_timeout(url):'
700 706 info = warning = error = debug
701 707 DEBUG = FakeLogger()
702 708 print(" fetching the file to establish a connection")
703 fo = urllib2.urlopen(url)
709 fo = urlreq.urlopen(url)
704 710 data1 = fo.read()
705 711 fo.close()
706 712
@@ -714,7 +720,7 b' def test_timeout(url):'
714 720 sys.stderr.write('\r')
715 721
716 722 print(" fetching the file a second time")
717 fo = urllib2.urlopen(url)
723 fo = urlreq.urlopen(url)
718 724 data2 = fo.read()
719 725 fo.close()
720 726
@@ -12,7 +12,6 b' import inspect'
12 12 import os
13 13 import random
14 14 import time
15 import urllib
16 15 import weakref
17 16
18 17 from .i18n import _
@@ -59,6 +58,8 b' from . import ('
59 58
60 59 release = lockmod.release
61 60 propertycache = util.propertycache
61 urlerr = util.urlerr
62 urlreq = util.urlreq
62 63 filecache = scmutil.filecache
63 64
64 65 class repofilecache(filecache):
@@ -366,7 +367,7 b' class localrepository(object):'
366 367 if self.ui.configbool('experimental', 'bundle2-advertise', True):
367 368 caps = set(caps)
368 369 capsblob = bundle2.encodecaps(bundle2.getrepocaps(self))
369 caps.add('bundle2=' + urllib.quote(capsblob))
370 caps.add('bundle2=' + urlreq.quote(capsblob))
370 371 return caps
371 372
372 373 def _applyopenerreqs(self):
@@ -11,8 +11,6 b' from __future__ import absolute_import'
11 11
12 12 import errno
13 13 import os
14 import urllib
15 import urllib2
16 14
17 15 from .i18n import _
18 16 from . import (
@@ -28,6 +26,9 b' from . import ('
28 26 util,
29 27 )
30 28
29 urlerr = util.urlerr
30 urlreq = util.urlreq
31
31 32 class httprangereader(object):
32 33 def __init__(self, url, opener):
33 34 # we assume opener has HTTPRangeHandler
@@ -45,7 +46,7 b' class httprangereader(object):'
45 46 def seek(self, pos):
46 47 self.pos = pos
47 48 def read(self, bytes=None):
48 req = urllib2.Request(self.url)
49 req = urlreq.request(self.url)
49 50 end = ''
50 51 if bytes:
51 52 end = self.pos + bytes - 1
@@ -56,10 +57,10 b' class httprangereader(object):'
56 57 f = self.opener.open(req)
57 58 data = f.read()
58 59 code = f.code
59 except urllib2.HTTPError as inst:
60 except urlerr.httperror as inst:
60 61 num = inst.code == 404 and errno.ENOENT or None
61 62 raise IOError(num, inst)
62 except urllib2.URLError as inst:
63 except urlerr.urlerror as inst:
63 64 raise IOError(None, inst.reason[1])
64 65
65 66 if code == 200:
@@ -92,7 +93,7 b' def build_opener(ui, authinfo):'
92 93 def __call__(self, path, mode='r', *args, **kw):
93 94 if mode not in ('r', 'rb'):
94 95 raise IOError('Permission denied')
95 f = "/".join((self.base, urllib.quote(path)))
96 f = "/".join((self.base, urlreq.quote(path)))
96 97 return httprangereader(f, urlopener)
97 98
98 99 def join(self, path):
@@ -11,7 +11,6 b' import cgi'
11 11 import os
12 12 import re
13 13 import time
14 import urllib
15 14
16 15 from . import (
17 16 encoding,
@@ -22,6 +21,9 b' from . import ('
22 21 util,
23 22 )
24 23
24 urlerr = util.urlerr
25 urlreq = util.urlreq
26
25 27 # filters are callables like:
26 28 # fn(obj)
27 29 # with:
@@ -299,7 +301,7 b' def revescape(text):'
299 301 Forward slashes are escaped twice to prevent web servers from prematurely
300 302 unescaping them. For example, "@foo bar/baz" becomes "@foo%20bar%252Fbaz".
301 303 """
302 return urllib.quote(text, safe='/@').replace('/', '%252F')
304 return urlreq.quote(text, safe='/@').replace('/', '%252F')
303 305
304 306 @templatefilter('rfc3339date')
305 307 def rfc3339date(text):
@@ -384,7 +386,7 b' def urlescape(text):'
384 386 """Any text. Escapes all "special" characters. For example,
385 387 "foo bar" becomes "foo%20bar".
386 388 """
387 return urllib.quote(text)
389 return urlreq.quote(text)
388 390
389 391 @templatefilter('user')
390 392 def userfilter(text):
@@ -13,8 +13,6 b' import base64'
13 13 import httplib
14 14 import os
15 15 import socket
16 import urllib
17 import urllib2
18 16
19 17 from .i18n import _
20 18 from . import (
@@ -26,13 +24,16 b' from . import ('
26 24 )
27 25 stringio = util.stringio
28 26
29 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm):
27 urlerr = util.urlerr
28 urlreq = util.urlreq
29
30 class passwordmgr(urlreq.httppasswordmgrwithdefaultrealm):
30 31 def __init__(self, ui):
31 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self)
32 urlreq.httppasswordmgrwithdefaultrealm.__init__(self)
32 33 self.ui = ui
33 34
34 35 def find_user_password(self, realm, authuri):
35 authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
36 authinfo = urlreq.httppasswordmgrwithdefaultrealm.find_user_password(
36 37 self, realm, authuri)
37 38 user, passwd = authinfo
38 39 if user and passwd:
@@ -72,10 +73,10 b' class passwordmgr(urllib2.HTTPPasswordMg'
72 73 self.ui.debug(msg % (user, passwd and '*' * len(passwd) or 'not set'))
73 74
74 75 def find_stored_password(self, authuri):
75 return urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
76 return urlreq.httppasswordmgrwithdefaultrealm.find_user_password(
76 77 self, None, authuri)
77 78
78 class proxyhandler(urllib2.ProxyHandler):
79 class proxyhandler(urlreq.proxyhandler):
79 80 def __init__(self, ui):
80 81 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
81 82 # XXX proxyauthinfo = None
@@ -121,7 +122,7 b' class proxyhandler(urllib2.ProxyHandler)'
121 122 except OSError:
122 123 pass
123 124
124 urllib2.ProxyHandler.__init__(self, proxies)
125 urlreq.proxyhandler.__init__(self, proxies)
125 126 self.ui = ui
126 127
127 128 def proxy_open(self, req, proxy, type_):
@@ -134,7 +135,7 b' class proxyhandler(urllib2.ProxyHandler)'
134 135 if e.startswith('.') and host.endswith(e[1:]):
135 136 return None
136 137
137 return urllib2.ProxyHandler.proxy_open(self, req, proxy, type_)
138 return urlreq.proxyhandler.proxy_open(self, req, proxy, type_)
138 139
139 140 def _gen_sendfile(orgsend):
140 141 def _sendfile(self, data):
@@ -148,7 +149,7 b' def _gen_sendfile(orgsend):'
148 149 orgsend(self, data)
149 150 return _sendfile
150 151
151 has_https = util.safehasattr(urllib2, 'HTTPSHandler')
152 has_https = util.safehasattr(urlreq, 'httpshandler')
152 153 if has_https:
153 154 try:
154 155 _create_connection = socket.create_connection
@@ -357,10 +358,10 b' if has_https:'
357 358 **sslutil.sslkwargs(self.ui, host))
358 359 sslutil.validator(self.ui, host)(self.sock)
359 360
360 class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler):
361 class httpshandler(keepalive.KeepAliveHandler, urlreq.httpshandler):
361 362 def __init__(self, ui):
362 363 keepalive.KeepAliveHandler.__init__(self)
363 urllib2.HTTPSHandler.__init__(self)
364 urlreq.httpshandler.__init__(self)
364 365 self.ui = ui
365 366 self.pwmgr = passwordmgr(self.ui)
366 367
@@ -403,9 +404,9 b' if has_https:'
403 404 conn.ui = self.ui
404 405 return conn
405 406
406 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler):
407 class httpdigestauthhandler(urlreq.httpdigestauthhandler):
407 408 def __init__(self, *args, **kwargs):
408 urllib2.HTTPDigestAuthHandler.__init__(self, *args, **kwargs)
409 urlreq.httpdigestauthhandler.__init__(self, *args, **kwargs)
409 410 self.retried_req = None
410 411
411 412 def reset_retry_count(self):
@@ -419,13 +420,13 b' class httpdigestauthhandler(urllib2.HTTP'
419 420 if req is not self.retried_req:
420 421 self.retried_req = req
421 422 self.retried = 0
422 return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed(
423 return urlreq.httpdigestauthhandler.http_error_auth_reqed(
423 424 self, auth_header, host, req, headers)
424 425
425 class httpbasicauthhandler(urllib2.HTTPBasicAuthHandler):
426 class httpbasicauthhandler(urlreq.httpbasicauthhandler):
426 427 def __init__(self, *args, **kwargs):
427 428 self.auth = None
428 urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
429 urlreq.httpbasicauthhandler.__init__(self, *args, **kwargs)
429 430 self.retried_req = None
430 431
431 432 def http_request(self, request):
@@ -451,7 +452,7 b' class httpbasicauthhandler(urllib2.HTTPB'
451 452 if req is not self.retried_req:
452 453 self.retried_req = req
453 454 self.retried = 0
454 return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
455 return urlreq.httpbasicauthhandler.http_error_auth_reqed(
455 456 self, auth_header, host, req, headers)
456 457
457 458 def retry_http_basic_auth(self, host, req, realm):
@@ -494,7 +495,7 b' def opener(ui, authinfo=None):'
494 495 handlers.extend((httpbasicauthhandler(passmgr),
495 496 httpdigestauthhandler(passmgr)))
496 497 handlers.extend([h(ui, passmgr) for h in handlerfuncs])
497 opener = urllib2.build_opener(*handlers)
498 opener = urlreq.buildopener(*handlers)
498 499
499 500 # 1.0 here is the _protocol_ version
500 501 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
@@ -508,6 +509,6 b' def open(ui, url_, data=None):'
508 509 url_, authinfo = u.authinfo()
509 510 else:
510 511 path = util.normpath(os.path.abspath(url_))
511 url_ = 'file://' + urllib.pathname2url(path)
512 url_ = 'file://' + urlreq.pathname2url(path)
512 513 authinfo = None
513 514 return opener(ui, authinfo).open(url_, data)
@@ -34,7 +34,6 b' import tempfile'
34 34 import textwrap
35 35 import time
36 36 import traceback
37 import urllib
38 37 import zlib
39 38
40 39 from . import (
@@ -50,11 +49,15 b' for attr in ('
50 49 'empty',
51 50 'queue',
52 51 'urlerr',
53 'urlreq',
52 # we do import urlreq, but we do it outside the loop
53 #'urlreq',
54 54 'stringio',
55 55 ):
56 56 globals()[attr] = getattr(pycompat, attr)
57 57
58 # This line is to make pyflakes happy:
59 urlreq = pycompat.urlreq
60
58 61 if os.name == 'nt':
59 62 from . import windows as platform
60 63 else:
@@ -2388,30 +2391,30 b' class url(object):'
2388 2391 if hasdriveletter(self.path):
2389 2392 s += '/'
2390 2393 if self.user:
2391 s += urllib.quote(self.user, safe=self._safechars)
2394 s += urlreq.quote(self.user, safe=self._safechars)
2392 2395 if self.passwd:
2393 s += ':' + urllib.quote(self.passwd, safe=self._safechars)
2396 s += ':' + urlreq.quote(self.passwd, safe=self._safechars)
2394 2397 if self.user or self.passwd:
2395 2398 s += '@'
2396 2399 if self.host:
2397 2400 if not (self.host.startswith('[') and self.host.endswith(']')):
2398 s += urllib.quote(self.host)
2401 s += urlreq.quote(self.host)
2399 2402 else:
2400 2403 s += self.host
2401 2404 if self.port:
2402 s += ':' + urllib.quote(self.port)
2405 s += ':' + urlreq.quote(self.port)
2403 2406 if self.host:
2404 2407 s += '/'
2405 2408 if self.path:
2406 2409 # TODO: similar to the query string, we should not unescape the
2407 2410 # path when we store it, the path might contain '%2f' = '/',
2408 2411 # which we should *not* escape.
2409 s += urllib.quote(self.path, safe=self._safepchars)
2412 s += urlreq.quote(self.path, safe=self._safepchars)
2410 2413 if self.query:
2411 2414 # we store the query in escaped form.
2412 2415 s += '?' + self.query
2413 2416 if self.fragment is not None:
2414 s += '#' + urllib.quote(self.fragment, safe=self._safepchars)
2417 s += '#' + urlreq.quote(self.fragment, safe=self._safepchars)
2415 2418 return s
2416 2419
2417 2420 def authinfo(self):
@@ -11,7 +11,6 b' import itertools'
11 11 import os
12 12 import sys
13 13 import tempfile
14 import urllib
15 14
16 15 from .i18n import _
17 16 from .node import (
@@ -31,6 +30,9 b' from . import ('
31 30 util,
32 31 )
33 32
33 urlerr = util.urlerr
34 urlreq = util.urlreq
35
34 36 bundle2required = _(
35 37 'incompatible Mercurial client; bundle2 required\n'
36 38 '(see https://www.mercurial-scm.org/wiki/IncompatibleClient)\n')
@@ -287,7 +289,7 b' class wirepeer(peer.peerrepository):'
287 289 branchmap = {}
288 290 for branchpart in d.splitlines():
289 291 branchname, branchheads = branchpart.split(' ', 1)
290 branchname = encoding.tolocal(urllib.unquote(branchname))
292 branchname = encoding.tolocal(urlreq.unquote(branchname))
291 293 branchheads = decodelist(branchheads)
292 294 branchmap[branchname] = branchheads
293 295 yield branchmap
@@ -632,7 +634,7 b' def branchmap(repo, proto):'
632 634 branchmap = repo.branchmap()
633 635 heads = []
634 636 for branch, nodes in branchmap.iteritems():
635 branchname = urllib.quote(encoding.fromlocal(branch))
637 branchname = urlreq.quote(encoding.fromlocal(branch))
636 638 branchnodes = encodelist(nodes)
637 639 heads.append('%s %s' % (branchname, branchnodes))
638 640 return '\n'.join(heads)
@@ -684,7 +686,7 b' def _capabilities(repo, proto):'
684 686 caps.append('streamreqs=%s' % ','.join(sorted(requiredformats)))
685 687 if repo.ui.configbool('experimental', 'bundle2-advertise', True):
686 688 capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo))
687 caps.append('bundle2=' + urllib.quote(capsblob))
689 caps.append('bundle2=' + urlreq.quote(capsblob))
688 690 caps.append('unbundle=%s' % ','.join(bundle2.bundlepriority))
689 691 caps.append(
690 692 'httpheader=%d' % repo.ui.configint('server', 'maxhttpheaderlen', 1024))
@@ -113,8 +113,8 b''
113 113 hgext/largefiles/lfutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
114 114 hgext/largefiles/localstore.py: error importing module: <ImportError> No module named 'lfutil' (line *) (glob)
115 115 hgext/largefiles/overrides.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at bundlerepo.py:*) (glob)
116 hgext/largefiles/proto.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
117 hgext/largefiles/remotestore.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
116 hgext/largefiles/proto.py: error importing: <ImportError> No module named 'httplib' (error at httppeer.py:*) (glob)
117 hgext/largefiles/remotestore.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at wireproto.py:*) (glob)
118 118 hgext/largefiles/reposetup.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
119 119 hgext/largefiles/uisetup.py: error importing module: <SyntaxError> invalid syntax (archival.py, line *) (line *) (glob)
120 120 hgext/largefiles/wirestore.py: error importing module: <ImportError> No module named 'lfutil' (line *) (glob)
@@ -135,7 +135,6 b''
135 135 mercurial/branchmap.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
136 136 mercurial/bundle*.py: invalid syntax: invalid syntax (<unknown>, line *) (glob)
137 137 mercurial/bundlerepo.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
138 mercurial/byterange.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
139 138 mercurial/changegroup.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
140 139 mercurial/changelog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
141 140 mercurial/cmdutil.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
@@ -147,7 +146,7 b''
147 146 mercurial/dirstate.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
148 147 mercurial/discovery.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
149 148 mercurial/dispatch.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
150 mercurial/exchange.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
149 mercurial/exchange.py: error importing module: <SyntaxError> invalid syntax (bundle*.py, line *) (line *) (glob)
151 150 mercurial/extensions.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
152 151 mercurial/filelog.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
153 152 mercurial/filemerge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
@@ -167,7 +166,7 b''
167 166 mercurial/hgweb/wsgicgi.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line *) (glob)
168 167 mercurial/hook.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
169 168 mercurial/httpclient/_readers.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
170 mercurial/httpconnection.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
169 mercurial/httpconnection.py: error importing: <ImportError> No module named 'httplib' (error at __init__.py:*) (glob)
171 170 mercurial/httppeer.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
172 171 mercurial/keepalive.py: error importing module: <ImportError> No module named 'httplib' (line *) (glob)
173 172 mercurial/localrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
@@ -186,7 +185,7 b''
186 185 mercurial/simplemerge.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
187 186 mercurial/sshpeer.py: error importing: <SyntaxError> invalid syntax (bundle*.py, line *) (error at wireproto.py:*) (glob)
188 187 mercurial/sshserver.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
189 mercurial/statichttprepo.py: error importing module: <ImportError> No module named 'urllib2' (line *) (glob)
188 mercurial/statichttprepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
190 189 mercurial/store.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
191 190 mercurial/streamclone.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
192 191 mercurial/subrepo.py: error importing: <AttributeError> 'dict' object has no attribute 'iteritems' (error at revset.py:*) (glob)
@@ -1,7 +1,6 b''
1 1 from __future__ import absolute_import, print_function
2 2
3 3 from mercurial import demandimport; demandimport.enable()
4 import urllib2
5 4 from mercurial import (
6 5 error,
7 6 ui as uimod,
@@ -9,6 +8,9 b' from mercurial import ('
9 8 util,
10 9 )
11 10
11 urlerr = util.urlerr
12 urlreq = util.urlreq
13
12 14 class myui(uimod.ui):
13 15 def interactive(self):
14 16 return False
@@ -104,7 +106,7 b" test({'x.prefix': 'http://example.org/fo"
104 106
105 107 def testauthinfo(fullurl, authurl):
106 108 print('URIs:', fullurl, authurl)
107 pm = urllib2.HTTPPasswordMgrWithDefaultRealm()
109 pm = urlreq.httppasswordmgrwithdefaultrealm()
108 110 pm.add_password(*util.url(fullurl).authinfo()[1])
109 111 print(pm.find_user_password('test', authurl))
110 112
General Comments 0
You need to be logged in to leave comments. Login now