Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 37645:72b0982cd509
debugcommands: perform handshake when obtaining httpv2 peer
If we obtain an httpv2peer directly, the instance doesn't have
an API descriptor and therefore doesn't know about the remote's
commands, feature support, etc. This doesn't matter now. But when
we implement the peer so it consults the API descriptor as part
of sending commands, it will.
So we change the logic for obtaining an http version 2 peer to
go through makepeer() so the peer will perform the handshake and
pass the API descriptor to the httpv2peer instance.
Tests changed because we now perform a ?cmd=capabilities when
obtaining version 2 peers.
The Content-Length header is globbed because compression info
will lack zstandard for pure builds.
Differential Revision: https://phab.mercurial-scm.org/D3296
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 12 Apr 2018 12:33:07 -0700 |
parents | 77c9ee77687c |
children | 516b5a5edae3 |
comparison
equal
deleted
inserted
replaced
37644:77c9ee77687c | 37645:72b0982cd509 |
---|---|
81 url as urlmod, | 81 url as urlmod, |
82 util, | 82 util, |
83 vfs as vfsmod, | 83 vfs as vfsmod, |
84 wireprotoframing, | 84 wireprotoframing, |
85 wireprotoserver, | 85 wireprotoserver, |
86 wireprototypes, | |
87 ) | 86 ) |
88 from .utils import ( | 87 from .utils import ( |
89 dateutil, | 88 dateutil, |
90 procutil, | 89 procutil, |
91 stringutil, | 90 stringutil, |
2909 | 2908 |
2910 opener = urlmod.opener(ui, authinfo, **openerargs) | 2909 opener = urlmod.opener(ui, authinfo, **openerargs) |
2911 | 2910 |
2912 if opts['peer'] == 'http2': | 2911 if opts['peer'] == 'http2': |
2913 ui.write(_('creating http peer for wire protocol version 2\n')) | 2912 ui.write(_('creating http peer for wire protocol version 2\n')) |
2914 peer = httppeer.httpv2peer( | 2913 # We go through makepeer() because we need an API descriptor for |
2915 ui, path, 'api/%s' % wireprototypes.HTTP_WIREPROTO_V2, | 2914 # the peer instance to be useful. |
2916 opener, httppeer.urlreq.request, {}) | 2915 with ui.configoverride({ |
2916 ('experimental', 'httppeer.advertise-v2'): True}): | |
2917 peer = httppeer.makepeer(ui, path, opener=opener) | |
2918 | |
2919 if not isinstance(peer, httppeer.httpv2peer): | |
2920 raise error.Abort(_('could not instantiate HTTP peer for ' | |
2921 'wire protocol version 2'), | |
2922 hint=_('the server may not have the feature ' | |
2923 'enabled or is not allowing this ' | |
2924 'client version')) | |
2925 | |
2917 elif opts['peer'] == 'raw': | 2926 elif opts['peer'] == 'raw': |
2918 ui.write(_('using raw connection to peer\n')) | 2927 ui.write(_('using raw connection to peer\n')) |
2919 peer = None | 2928 peer = None |
2920 elif opts['peer']: | 2929 elif opts['peer']: |
2921 raise error.Abort(_('--peer %s not supported with HTTP peers') % | 2930 raise error.Abort(_('--peer %s not supported with HTTP peers') % |