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