Moving away from the vendored package.
Again, our encoder normalizes keys differently from the vendored
package (for now), hence the test changes.
| pulkit | 
| hg-reviewers | 
Moving away from the vendored package.
Again, our encoder normalizes keys differently from the vendored
package (for now), hence the test changes.
| Automatic diff as part of commit; lint not applicable. | 
| Automatic diff as part of commit; unit tests not applicable. | 
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/wireprotoserver.py (6 lines) | |||
| M | tests/test-http-protocol.t (2 lines) | |||
| M | tests/test-wireproto-command-capabilities.t (8 lines) | 
| Status | Author | Revision | |
|---|---|---|---|
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | ||
| Closed | indygreg | 
| # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net> | ||||
| # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | ||||
| # | # | ||||
| # This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
| # GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
| from __future__ import absolute_import | from __future__ import absolute_import | ||||
| import contextlib | import contextlib | ||||
| import struct | import struct | ||||
| import sys | import sys | ||||
| import threading | import threading | ||||
| from .i18n import _ | from .i18n import _ | ||||
| from .thirdparty import ( | |||||
| cbor, | |||||
| ) | |||||
| from . import ( | from . import ( | ||||
| encoding, | encoding, | ||||
| error, | error, | ||||
| pycompat, | pycompat, | ||||
| util, | util, | ||||
| wireprototypes, | wireprototypes, | ||||
| wireprotov1server, | wireprotov1server, | ||||
| wireprotov2server, | wireprotov2server, | ||||
| ) | ) | ||||
| from .utils import ( | from .utils import ( | ||||
| cborutil, | |||||
| interfaceutil, | interfaceutil, | ||||
| procutil, | procutil, | ||||
| ) | ) | ||||
| stringio = util.stringio | stringio = util.stringio | ||||
| urlerr = util.urlerr | urlerr = util.urlerr | ||||
| urlreq = util.urlreq | urlreq = util.urlreq | ||||
| # TODO allow this to be configurable. | # TODO allow this to be configurable. | ||||
| 'apibase': 'api/', | 'apibase': 'api/', | ||||
| 'apis': descriptors, | 'apis': descriptors, | ||||
| 'v1capabilities': v1caps.data, | 'v1capabilities': v1caps.data, | ||||
| } | } | ||||
| res.status = b'200 OK' | res.status = b'200 OK' | ||||
| res.headers[b'Content-Type'] = b'application/mercurial-cbor' | res.headers[b'Content-Type'] = b'application/mercurial-cbor' | ||||
| res.setbodybytes(cbor.dumps(m, canonical=True)) | res.setbodybytes(b''.join(cborutil.streamencode(m))) | ||||
| return True | return True | ||||
| def _callhttp(repo, req, res, proto, cmd): | def _callhttp(repo, req, res, proto, cmd): | ||||
| # Avoid cycle involving hg module. | # Avoid cycle involving hg module. | ||||
| from .hgweb import common as hgwebcommon | from .hgweb import common as hgwebcommon | ||||
| def genversion2(gen, engine, engineopts): | def genversion2(gen, engine, engineopts): | ||||
| s> \r\n | s> \r\n | ||||
| s> makefile('rb', None) | s> makefile('rb', None) | ||||
| s> HTTP/1.1 200 OK\r\n | s> HTTP/1.1 200 OK\r\n | ||||
| s> Server: testing stub value\r\n | s> Server: testing stub value\r\n | ||||
| s> Date: $HTTP_DATE$\r\n | s> Date: $HTTP_DATE$\r\n | ||||
| s> Content-Type: application/mercurial-cbor\r\n | s> Content-Type: application/mercurial-cbor\r\n | ||||
| s> Content-Length: *\r\n (glob) | s> Content-Length: *\r\n (glob) | ||||
| s> \r\n | s> \r\n | ||||
| s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | ||||
| sending heads command | sending heads command | ||||
| s> POST /api/exp-http-v2-0001/ro/heads HTTP/1.1\r\n | s> POST /api/exp-http-v2-0001/ro/heads HTTP/1.1\r\n | ||||
| s> Accept-Encoding: identity\r\n | s> Accept-Encoding: identity\r\n | ||||
| s> accept: application/mercurial-exp-framing-0005\r\n | s> accept: application/mercurial-exp-framing-0005\r\n | ||||
| s> content-type: application/mercurial-exp-framing-0005\r\n | s> content-type: application/mercurial-exp-framing-0005\r\n | ||||
| s> content-length: 20\r\n | s> content-length: 20\r\n | ||||
| s> host: $LOCALIP:$HGPORT\r\n (glob) | s> host: $LOCALIP:$HGPORT\r\n (glob) | ||||
| s> user-agent: Mercurial debugwireproto\r\n | s> user-agent: Mercurial debugwireproto\r\n | ||||
| s> \r\n | s> \r\n | ||||
| s> makefile('rb', None) | s> makefile('rb', None) | ||||
| s> HTTP/1.1 200 OK\r\n | s> HTTP/1.1 200 OK\r\n | ||||
| s> Server: testing stub value\r\n | s> Server: testing stub value\r\n | ||||
| s> Date: $HTTP_DATE$\r\n | s> Date: $HTTP_DATE$\r\n | ||||
| s> Content-Type: application/mercurial-cbor\r\n | s> Content-Type: application/mercurial-cbor\r\n | ||||
| s> Content-Length: *\r\n (glob) | s> Content-Length: *\r\n (glob) | ||||
| s> \r\n | s> \r\n | ||||
| s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | s> \xa3GapibaseDapi/Dapis\xa0Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | ||||
| cbor> { | cbor> { | ||||
| b'apibase': b'api/', | b'apibase': b'api/', | ||||
| b'apis': {}, | b'apis': {}, | ||||
| b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash' | b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash' | ||||
| } | } | ||||
| Restart server to enable HTTPv2 | Restart server to enable HTTPv2 | ||||
| s> \r\n | s> \r\n | ||||
| s> makefile('rb', None) | s> makefile('rb', None) | ||||
| s> HTTP/1.1 200 OK\r\n | s> HTTP/1.1 200 OK\r\n | ||||
| s> Server: testing stub value\r\n | s> Server: testing stub value\r\n | ||||
| s> Date: $HTTP_DATE$\r\n | s> Date: $HTTP_DATE$\r\n | ||||
| s> Content-Type: application/mercurial-cbor\r\n | s> Content-Type: application/mercurial-cbor\r\n | ||||
| s> Content-Length: *\r\n (glob) | s> Content-Length: *\r\n (glob) | ||||
| s> \r\n | s> \r\n | ||||
| s> \xa3Dapis\xa0GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | s> \xa3GapibaseDapi/Dapis\xa0Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | ||||
| cbor> { | cbor> { | ||||
| b'apibase': b'api/', | b'apibase': b'api/', | ||||
| b'apis': {}, | b'apis': {}, | ||||
| b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash' | b'v1capabilities': b'batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash' | ||||
| } | } | ||||
| Request for HTTPv2 service returns information about it | Request for HTTPv2 service returns information about it | ||||
| s> \r\n | s> \r\n | ||||
| s> makefile('rb', None) | s> makefile('rb', None) | ||||
| s> HTTP/1.1 200 OK\r\n | s> HTTP/1.1 200 OK\r\n | ||||
| s> Server: testing stub value\r\n | s> Server: testing stub value\r\n | ||||
| s> Date: $HTTP_DATE$\r\n | s> Date: $HTTP_DATE$\r\n | ||||
| s> Content-Type: application/mercurial-cbor\r\n | s> Content-Type: application/mercurial-cbor\r\n | ||||
| s> Content-Length: *\r\n (glob) | s> Content-Length: *\r\n (glob) | ||||
| s> \r\n | s> \r\n | ||||
| s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | ||||
| cbor> { | cbor> { | ||||
| b'apibase': b'api/', | b'apibase': b'api/', | ||||
| b'apis': { | b'apis': { | ||||
| b'exp-http-v2-0001': { | b'exp-http-v2-0001': { | ||||
| b'commands': { | b'commands': { | ||||
| b'branchmap': { | b'branchmap': { | ||||
| b'args': {}, | b'args': {}, | ||||
| b'permissions': [ | b'permissions': [ | ||||
| s> \r\n | s> \r\n | ||||
| s> makefile('rb', None) | s> makefile('rb', None) | ||||
| s> HTTP/1.1 200 OK\r\n | s> HTTP/1.1 200 OK\r\n | ||||
| s> Server: testing stub value\r\n | s> Server: testing stub value\r\n | ||||
| s> Date: $HTTP_DATE$\r\n | s> Date: $HTTP_DATE$\r\n | ||||
| s> Content-Type: application/mercurial-cbor\r\n | s> Content-Type: application/mercurial-cbor\r\n | ||||
| s> Content-Length: *\r\n (glob) | s> Content-Length: *\r\n (glob) | ||||
| s> \r\n | s> \r\n | ||||
| s> \xa3Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Eheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyCnewCnewColdColdInamespaceBnsKpermissions\x81DpushHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullIbranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullKcompression\x81\xa1DnameDzlibNrawrepoformats\x82LgeneraldeltaHrevlogv1Qframingmediatypes\x81X&application/mercurial-exp-framing-0005GapibaseDapi/Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | s> \xa3GapibaseDapi/Dapis\xa1Pexp-http-v2-0001\xa4Hcommands\xa7Ibranchmap\xa2Dargs\xa0Kpermissions\x81DpullLcapabilities\xa2Dargs\xa0Kpermissions\x81DpullEheads\xa2Dargs\xa1Jpubliconly\xf4Kpermissions\x81DpullEknown\xa2Dargs\xa1Enodes\x81HdeadbeefKpermissions\x81DpullHlistkeys\xa2Dargs\xa1InamespaceBnsKpermissions\x81DpullFlookup\xa2Dargs\xa1CkeyCfooKpermissions\x81DpullGpushkey\xa2Dargs\xa4CkeyCkeyInamespaceBnsCnewCnewColdColdKpermissions\x81DpushKcompression\x81\xa1DnameDzlibQframingmediatypes\x81X&application/mercurial-exp-framing-0005Nrawrepoformats\x82LgeneraldeltaHrevlogv1Nv1capabilitiesY\x01\xc5batch branchmap $USUAL_BUNDLE2_CAPS_SERVER$ changegroupsubset compression=$BUNDLE2_COMPRESSIONS$ getbundle httpheader=1024 httpmediatype=0.1rx,0.1tx,0.2tx known lookup pushkey streamreqs=generaldelta,revlogv1 unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash | ||||
| sending capabilities command | sending capabilities command | ||||
| s> POST /api/exp-http-v2-0001/ro/capabilities HTTP/1.1\r\n | s> POST /api/exp-http-v2-0001/ro/capabilities HTTP/1.1\r\n | ||||
| s> Accept-Encoding: identity\r\n | s> Accept-Encoding: identity\r\n | ||||
| s> *\r\n (glob) | s> *\r\n (glob) | ||||
| s> content-type: application/mercurial-exp-framing-0005\r\n | s> content-type: application/mercurial-exp-framing-0005\r\n | ||||
| s> content-length: 27\r\n | s> content-length: 27\r\n | ||||
| s> host: $LOCALIP:$HGPORT\r\n (glob) | s> host: $LOCALIP:$HGPORT\r\n (glob) | ||||
| s> user-agent: Mercurial debugwireproto\r\n | s> user-agent: Mercurial debugwireproto\r\n | ||||