Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG3e1688711efd: wireproto: turn client capabilities into sets, sorted on the wire
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/httppeer.py (10 lines) | |||
M | mercurial/sshpeer.py (7 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | joerg.sonnenberger | ||
Closed | joerg.sonnenberger | ||
Closed | joerg.sonnenberger |
elif data is not None: | elif data is not None: | ||||
size = len(data) | size = len(data) | ||||
if data is not None and r'Content-Type' not in headers: | if data is not None and r'Content-Type' not in headers: | ||||
headers[r'Content-Type'] = r'application/mercurial-0.1' | headers[r'Content-Type'] = r'application/mercurial-0.1' | ||||
# Tell the server we accept application/mercurial-0.2 and multiple | # Tell the server we accept application/mercurial-0.2 and multiple | ||||
# compression formats if the server is capable of emitting those | # compression formats if the server is capable of emitting those | ||||
# payloads. | # payloads. | ||||
protoparams = [] | protoparams = set() | ||||
mediatypes = set() | mediatypes = set() | ||||
if self._caps is not None: | if self._caps is not None: | ||||
mt = self.capable('httpmediatype') | mt = self.capable('httpmediatype') | ||||
if mt: | if mt: | ||||
protoparams.append('0.1') | protoparams.add('0.1') | ||||
mediatypes = set(mt.split(',')) | mediatypes = set(mt.split(',')) | ||||
if '0.2tx' in mediatypes: | if '0.2tx' in mediatypes: | ||||
protoparams.append('0.2') | protoparams.add('0.2') | ||||
if '0.2tx' in mediatypes and self.capable('compression'): | if '0.2tx' in mediatypes and self.capable('compression'): | ||||
# We /could/ compare supported compression formats and prune | # We /could/ compare supported compression formats and prune | ||||
# non-mutually supported or error if nothing is mutually supported. | # non-mutually supported or error if nothing is mutually supported. | ||||
# For now, send the full list to the server and have it error. | # For now, send the full list to the server and have it error. | ||||
comps = [e.wireprotosupport().name for e in | comps = [e.wireprotosupport().name for e in | ||||
util.compengines.supportedwireengines(util.CLIENTROLE)] | util.compengines.supportedwireengines(util.CLIENTROLE)] | ||||
protoparams.append('comp=%s' % ','.join(comps)) | protoparams.add('comp=%s' % ','.join(comps)) | ||||
if protoparams: | if protoparams: | ||||
protoheaders = encodevalueinheaders(' '.join(protoparams), | protoheaders = encodevalueinheaders(' '.join(sorted(protoparams)), | ||||
'X-HgProto', | 'X-HgProto', | ||||
headersize or 1024) | headersize or 1024) | ||||
for header, value in protoheaders: | for header, value in protoheaders: | ||||
headers[header] = value | headers[header] = value | ||||
varyheaders.append(header) | varyheaders.append(header) | ||||
if varyheaders: | if varyheaders: | ||||
headers[r'Vary'] = r','.join(varyheaders) | headers[r'Vary'] = r','.join(varyheaders) |
return proc, stdin, stdout, stderr | return proc, stdin, stdout, stderr | ||||
def _clientcapabilities(): | def _clientcapabilities(): | ||||
"""Return list of capabilities of this client. | """Return list of capabilities of this client. | ||||
Returns a list of capabilities that are supported by this client. | Returns a list of capabilities that are supported by this client. | ||||
""" | """ | ||||
protoparams = [] | protoparams = set() | ||||
comps = [e.wireprotosupport().name for e in | comps = [e.wireprotosupport().name for e in | ||||
util.compengines.supportedwireengines(util.CLIENTROLE)] | util.compengines.supportedwireengines(util.CLIENTROLE)] | ||||
protoparams.append('comp=%s' % ','.join(comps)) | protoparams.add('comp=%s' % ','.join(comps)) | ||||
return protoparams | return protoparams | ||||
def _performhandshake(ui, stdin, stdout, stderr): | def _performhandshake(ui, stdin, stdout, stderr): | ||||
def badresponse(): | def badresponse(): | ||||
# Flush any output on stderr. | # Flush any output on stderr. | ||||
_forwardoutput(ui, stderr) | _forwardoutput(ui, stderr) | ||||
msg = _('no suitable response from remote hg') | msg = _('no suitable response from remote hg') | ||||
remotepath, sshenv) | remotepath, sshenv) | ||||
peer = makepeer(ui, path, proc, stdin, stdout, stderr) | peer = makepeer(ui, path, proc, stdin, stdout, stderr) | ||||
# Finally, if supported by the server, notify it about our own | # Finally, if supported by the server, notify it about our own | ||||
# capabilities. | # capabilities. | ||||
if 'protocaps' in peer.capabilities(): | if 'protocaps' in peer.capabilities(): | ||||
try: | try: | ||||
peer._call("protocaps", caps=' '.join(_clientcapabilities())) | peer._call("protocaps", | ||||
caps=' '.join(sorted(_clientcapabilities()))) | |||||
except IOError: | except IOError: | ||||
peer._cleanup() | peer._cleanup() | ||||
raise error.RepoError(_('capability exchange failed')) | raise error.RepoError(_('capability exchange failed')) | ||||
return peer | return peer |