comparison mercurial/wireproto.py @ 28883:032c4c2f802a

pycompat: switch to util.urlreq/util.urlerr for py3 compat
author timeless <timeless@mozdev.org>
date Wed, 06 Apr 2016 23:22:12 +0000
parents ae53ecc47414
children 7996c3acc33b
comparison
equal deleted inserted replaced
28882:800ec7c048b0 28883:032c4c2f802a
9 9
10 import itertools 10 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 (
18 bin, 17 bin,
19 hex, 18 hex,
28 peer, 27 peer,
29 pushkey as pushkeymod, 28 pushkey as pushkeymod,
30 streamclone, 29 streamclone,
31 util, 30 util,
32 ) 31 )
32
33 urlerr = util.urlerr
34 urlreq = util.urlreq
33 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')
37 39
285 d = f.value 287 d = f.value
286 try: 288 try:
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(urllib.unquote(branchname)) 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
294 except TypeError: 296 except TypeError:
295 self._abort(error.ResponseError(_("unexpected response:"), d)) 297 self._abort(error.ResponseError(_("unexpected response:"), d))
630 @wireprotocommand('branchmap') 632 @wireprotocommand('branchmap')
631 def branchmap(repo, proto): 633 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 = urllib.quote(encoding.fromlocal(branch)) 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)
639 641
640 @wireprotocommand('branches', 'nodes') 642 @wireprotocommand('branches', 'nodes')
682 # otherwise, add 'streamreqs' detailing our local revlog format 684 # otherwise, add 'streamreqs' detailing our local revlog format
683 else: 685 else:
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=' + urllib.quote(capsblob)) 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))
691 if repo.ui.configbool('experimental', 'httppostargs', False): 693 if repo.ui.configbool('experimental', 'httppostargs', False):
692 caps.append('httppostargs') 694 caps.append('httppostargs')