##// END OF EJS Templates
wireprotov2: define and implement "manifestdata" command...
wireprotov2: define and implement "manifestdata" command The added command can be used for obtaining manifest data. Given a manifest path and set of manifest nodes, data about manifests can be retrieved. Unlike changeset data, we wish to emit deltas to describe manifest revisions. So the command uses the relatively new API for building delta requests and emitting them. The code calls into deltaparent(), which I'm not very keen of. There's still work to be done in delta generation land so implementation details of storage (e.g. exactly one delta is stored/available) don't creep into higher levels. But we can worry about this later (there is already a TODO on imanifestorage tracking this). On the subject of parent deltas, the server assumes parent revisions exist on the receiving end. This is obviously wrong for shallow clone. I've added TODOs to add a mechanism to the command to allow clients to specify desired behavior. This shouldn't be too difficult to implement. Another big change is that the client must explicitly request manifest nodes to retrieve. This is a major departure from "getbundle," where the server derives relevant manifests as it iterates changesets and sends them automatically. As implemented, the client must transmit each requested node to the server. At 20 bytes per node, we're looking at 2 MB per 100,000 nodes. Plus wire encoding overhead. This isn't ideal for clients with limited upload bandwidth. I plan to address this in the future by allowing alternate mechanisms for defining the revisions to retrieve. One idea is to define a range of changeset revisions whose manifest revisions to retrieve (similar to how "changesetdata" works). We almost certainly want an API to look up an individual manifest by node. And that's where I've chosen to start with the implementation. Again, a theme of this early exchangev2 work is I want to start by building primitives for accessing raw repository data first and see how far we can get with those before we need more complexity. Differential Revision: https://phab.mercurial-scm.org/D4488

File last commit:

r39595:07b58266 default
r39673:c7a7c7e8 default
Show More
test-wireproto-command-pushkey.t
109 lines | 3.4 KiB | text/troff | Tads3Lexer
/ tests / test-wireproto-command-pushkey.t
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 $ . $TESTDIR/wireprotohelpers.sh
$ hg init server
$ enablehttpv2 server
$ cd server
$ cat >> .hg/hgrc << EOF
> [web]
> push_ssl = false
> allow-push = *
> EOF
$ hg debugdrawdag << EOF
> C D
> |/
> B
> |
> A
> EOF
$ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log
$ cat hg.pid > $DAEMON_PIDS
pushkey for a bookmark works
$ sendhttpv2peer << EOF
> command pushkey
> namespace bookmarks
> key @
> old
> new 426bada5c67598ca65036d57d9e4b64b0c1ce7a0
> EOF
creating http peer for wire protocol version 2
sending pushkey command
s> *\r\n (glob)
s> Accept-Encoding: identity\r\n
Gregory Szorc
wireprotov2: change command response protocol to include a leading map...
r37743 s> accept: application/mercurial-exp-framing-0005\r\n
s> content-type: application/mercurial-exp-framing-0005\r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> content-length: 105\r\n
s> host: $LOCALIP:$HGPORT\r\n (glob)
s> user-agent: Mercurial debugwireproto\r\n
s> \r\n
Gregory Szorc
wireprotoframing: use our CBOR module...
r39477 s> a\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa4CkeyA@InamespaceIbookmarksCnewX(426bada5c67598ca65036d57d9e4b64b0c1ce7a0Cold@DnameGpushkey
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> makefile('rb', None)
s> HTTP/1.1 200 OK\r\n
s> Server: testing stub value\r\n
s> Date: $HTTP_DATE$\r\n
Gregory Szorc
wireprotov2: change command response protocol to include a leading map...
r37743 s> Content-Type: application/mercurial-exp-framing-0005\r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> Transfer-Encoding: chunked\r\n
s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 s> 13\r\n
s> \x0b\x00\x00\x01\x00\x02\x011
s> \xa1FstatusBok
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
s> 9\r\n
s> \x01\x00\x00\x01\x00\x02\x001
s> \xf5
s> \r\n
received frame(size=1; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
s> 8\r\n
s> \x00\x00\x00\x01\x00\x02\x002
s> \r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> 0\r\n
s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
Gregory Szorc
wireprotov2: decode responses to their expected types...
r37739 response: True
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555
$ sendhttpv2peer << EOF
> command listkeys
> namespace bookmarks
> EOF
creating http peer for wire protocol version 2
sending listkeys command
s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n
s> Accept-Encoding: identity\r\n
Gregory Szorc
wireprotov2: change command response protocol to include a leading map...
r37743 s> accept: application/mercurial-exp-framing-0005\r\n
s> content-type: application/mercurial-exp-framing-0005\r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> content-length: 49\r\n
s> host: $LOCALIP:$HGPORT\r\n (glob)
s> user-agent: Mercurial debugwireproto\r\n
s> \r\n
s> )\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1InamespaceIbookmarksDnameHlistkeys
s> makefile('rb', None)
s> HTTP/1.1 200 OK\r\n
s> Server: testing stub value\r\n
s> Date: $HTTP_DATE$\r\n
Gregory Szorc
wireprotov2: change command response protocol to include a leading map...
r37743 s> Content-Type: application/mercurial-exp-framing-0005\r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> Transfer-Encoding: chunked\r\n
s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 s> 13\r\n
s> \x0b\x00\x00\x01\x00\x02\x011
s> \xa1FstatusBok
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
s> 35\r\n
s> -\x00\x00\x01\x00\x02\x001
s> \xa1A@X(426bada5c67598ca65036d57d9e4b64b0c1ce7a0
s> \r\n
received frame(size=45; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
s> 8\r\n
s> \x00\x00\x00\x01\x00\x02\x002
s> \r\n
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555 s> 0\r\n
s> \r\n
Gregory Szorc
wireprotov2: implement commands as a generator of objects...
r39595 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
Gregory Szorc
stringutil: teach pprint() to indent...
r39414 response: {
b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'
}
Gregory Szorc
wireproto: port pushkey command to wire protocol version 2...
r37555
$ cat error.log