equal
deleted
inserted
replaced
150 import errno |
150 import errno |
151 import re |
151 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 ( |
159 changegroup, |
158 changegroup, |
160 error, |
159 error, |
162 pushkey, |
161 pushkey, |
163 tags, |
162 tags, |
164 url, |
163 url, |
165 util, |
164 util, |
166 ) |
165 ) |
|
166 |
|
167 urlerr = util.urlerr |
|
168 urlreq = util.urlreq |
167 |
169 |
168 _pack = struct.pack |
170 _pack = struct.pack |
169 _unpack = struct.unpack |
171 _unpack = struct.unpack |
170 |
172 |
171 _fstreamparamsize = '>i' |
173 _fstreamparamsize = '>i' |
455 if '=' not in line: |
457 if '=' not in line: |
456 key, vals = line, () |
458 key, vals = line, () |
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 = urllib.unquote(key) |
462 key = urlreq.unquote(key) |
461 vals = [urllib.unquote(v) for v in vals] |
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 |
465 def encodecaps(caps): |
467 def encodecaps(caps): |
466 """encode a bundle2 caps dictionary into a bytes blob""" |
468 """encode a bundle2 caps dictionary into a bytes blob""" |
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 = urllib.quote(ca) |
472 ca = urlreq.quote(ca) |
471 vals = [urllib.quote(v) for v in vals] |
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) |
475 return '\n'.join(chunks) |
477 return '\n'.join(chunks) |
476 |
478 |
568 |
570 |
569 def _paramchunk(self): |
571 def _paramchunk(self): |
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 = urllib.quote(par) |
575 par = urlreq.quote(par) |
574 if value is not None: |
576 if value is not None: |
575 value = urllib.quote(value) |
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) |
579 |
581 |
580 def _getcorechunk(self): |
582 def _getcorechunk(self): |
689 def _processallparams(self, paramsblock): |
691 def _processallparams(self, paramsblock): |
690 """""" |
692 """""" |
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 = [urllib.unquote(i) for i in p] |
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) |
698 params[p[0]] = p[1] |
700 params[p[0]] = p[1] |
699 return params |
701 return params |
1267 def bundle2caps(remote): |
1269 def bundle2caps(remote): |
1268 """return the bundle capabilities of a peer as dict""" |
1270 """return the bundle capabilities of a peer as dict""" |
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 = urllib.unquote(remote.capable('bundle2')) |
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): |
1276 """extract the list of supported obsmarkers versions from a bundle2caps dict |
1278 """extract the list of supported obsmarkers versions from a bundle2caps dict |
1277 """ |
1279 """ |