comparison tests/test-http-api-httpv2.t @ 40176:41263df08109

wireprotov2: change how revisions are specified to changesetdata Right now, we have a handful of arguments for specifying the revisions whose data should be returned. Defining how all these arguments interact when various combinations are present is difficult. This commit establishes a new, generic mechanism for specifying revisions. Instead of a hodgepodge of arguments defining things, we have a list of dicts that specify revision selectors. The final set of revisions is a union of all these selectors. We implement support for specifying revisions based on: * An explicit list of changeset revisions * An explicit list of changeset revisions plus ancestry depth * A DAG range between changeset roots and heads If you squint hard enough, this problem has already been solved by revsets. But I'm reluctant to expose revsets to the wire protocol because that would require servers to implement a revset parser. Plus there are security and performance implications: the set of revision selectors needs to be narrowly and specifically tailored for what is appropriate to be executing on a server. Perhaps there would be a way for us to express the "parse tree" of a revset query, for example. I'm not sure. We can explore this space another time. For now, the new mechanism should bring sufficient flexibility while remaining relatively simple. The selector "types" are prefixed with "changeset" because I plan to add manifest and file-flavored selectors as well. This will enable us to e.g. select file revisions based on a range of changeset revisions. Differential Revision: https://phab.mercurial-scm.org/D4979
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 08 Oct 2018 18:17:12 -0700
parents b5bf3dd6ec5b
children 090a797f2b47
comparison
equal deleted inserted replaced
40175:6c42409691ec 40176:41263df08109
16 $ sendhttpraw << EOF 16 $ sendhttpraw << EOF
17 > httprequest GET api/$HTTPV2 17 > httprequest GET api/$HTTPV2
18 > user-agent: test 18 > user-agent: test
19 > EOF 19 > EOF
20 using raw connection to peer 20 using raw connection to peer
21 s> GET /api/exp-http-v2-0002 HTTP/1.1\r\n 21 s> GET /api/exp-http-v2-0003 HTTP/1.1\r\n
22 s> Accept-Encoding: identity\r\n 22 s> Accept-Encoding: identity\r\n
23 s> user-agent: test\r\n 23 s> user-agent: test\r\n
24 s> host: $LOCALIP:$HGPORT\r\n (glob) 24 s> host: $LOCALIP:$HGPORT\r\n (glob)
25 s> \r\n 25 s> \r\n
26 s> makefile('rb', None) 26 s> makefile('rb', None)
28 s> Server: testing stub value\r\n 28 s> Server: testing stub value\r\n
29 s> Date: $HTTP_DATE$\r\n 29 s> Date: $HTTP_DATE$\r\n
30 s> Content-Type: text/plain\r\n 30 s> Content-Type: text/plain\r\n
31 s> Content-Length: 33\r\n 31 s> Content-Length: 33\r\n
32 s> \r\n 32 s> \r\n
33 s> API exp-http-v2-0002 not enabled\n 33 s> API exp-http-v2-0003 not enabled\n
34 34
35 Restart server with support for HTTP v2 API 35 Restart server with support for HTTP v2 API
36 36
37 $ killdaemons.py 37 $ killdaemons.py
38 $ enablehttpv2 server 38 $ enablehttpv2 server
44 $ sendhttpraw << EOF 44 $ sendhttpraw << EOF
45 > httprequest POST api/$HTTPV2/ro/badcommand 45 > httprequest POST api/$HTTPV2/ro/badcommand
46 > user-agent: test 46 > user-agent: test
47 > EOF 47 > EOF
48 using raw connection to peer 48 using raw connection to peer
49 s> POST /api/exp-http-v2-0002/ro/badcommand HTTP/1.1\r\n 49 s> POST /api/exp-http-v2-0003/ro/badcommand HTTP/1.1\r\n
50 s> Accept-Encoding: identity\r\n 50 s> Accept-Encoding: identity\r\n
51 s> user-agent: test\r\n 51 s> user-agent: test\r\n
52 s> host: $LOCALIP:$HGPORT\r\n (glob) 52 s> host: $LOCALIP:$HGPORT\r\n (glob)
53 s> \r\n 53 s> \r\n
54 s> makefile('rb', None) 54 s> makefile('rb', None)
65 $ sendhttpraw << EOF 65 $ sendhttpraw << EOF
66 > httprequest GET api/$HTTPV2/ro/customreadonly 66 > httprequest GET api/$HTTPV2/ro/customreadonly
67 > user-agent: test 67 > user-agent: test
68 > EOF 68 > EOF
69 using raw connection to peer 69 using raw connection to peer
70 s> GET /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 70 s> GET /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
71 s> Accept-Encoding: identity\r\n 71 s> Accept-Encoding: identity\r\n
72 s> user-agent: test\r\n 72 s> user-agent: test\r\n
73 s> host: $LOCALIP:$HGPORT\r\n (glob) 73 s> host: $LOCALIP:$HGPORT\r\n (glob)
74 s> \r\n 74 s> \r\n
75 s> makefile('rb', None) 75 s> makefile('rb', None)
86 $ sendhttpraw << EOF 86 $ sendhttpraw << EOF
87 > httprequest POST api/$HTTPV2/ro/customreadonly 87 > httprequest POST api/$HTTPV2/ro/customreadonly
88 > user-agent: test 88 > user-agent: test
89 > EOF 89 > EOF
90 using raw connection to peer 90 using raw connection to peer
91 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 91 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
92 s> Accept-Encoding: identity\r\n 92 s> Accept-Encoding: identity\r\n
93 s> user-agent: test\r\n 93 s> user-agent: test\r\n
94 s> host: $LOCALIP:$HGPORT\r\n (glob) 94 s> host: $LOCALIP:$HGPORT\r\n (glob)
95 s> \r\n 95 s> \r\n
96 s> makefile('rb', None) 96 s> makefile('rb', None)
108 > httprequest POST api/$HTTPV2/ro/customreadonly 108 > httprequest POST api/$HTTPV2/ro/customreadonly
109 > accept: invalid 109 > accept: invalid
110 > user-agent: test 110 > user-agent: test
111 > EOF 111 > EOF
112 using raw connection to peer 112 using raw connection to peer
113 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 113 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
114 s> Accept-Encoding: identity\r\n 114 s> Accept-Encoding: identity\r\n
115 s> accept: invalid\r\n 115 s> accept: invalid\r\n
116 s> user-agent: test\r\n 116 s> user-agent: test\r\n
117 s> host: $LOCALIP:$HGPORT\r\n (glob) 117 s> host: $LOCALIP:$HGPORT\r\n (glob)
118 s> \r\n 118 s> \r\n
132 > accept: $MEDIATYPE 132 > accept: $MEDIATYPE
133 > user-agent: test 133 > user-agent: test
134 > content-type: badmedia 134 > content-type: badmedia
135 > EOF 135 > EOF
136 using raw connection to peer 136 using raw connection to peer
137 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 137 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
138 s> Accept-Encoding: identity\r\n 138 s> Accept-Encoding: identity\r\n
139 s> accept: application/mercurial-exp-framing-0006\r\n 139 s> accept: application/mercurial-exp-framing-0006\r\n
140 s> content-type: badmedia\r\n 140 s> content-type: badmedia\r\n
141 s> user-agent: test\r\n 141 s> user-agent: test\r\n
142 s> host: $LOCALIP:$HGPORT\r\n (glob) 142 s> host: $LOCALIP:$HGPORT\r\n (glob)
158 > content-type: $MEDIATYPE 158 > content-type: $MEDIATYPE
159 > user-agent: test 159 > user-agent: test
160 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'} 160 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
161 > EOF 161 > EOF
162 using raw connection to peer 162 using raw connection to peer
163 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 163 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
164 s> Accept-Encoding: identity\r\n 164 s> Accept-Encoding: identity\r\n
165 s> *\r\n (glob) 165 s> *\r\n (glob)
166 s> content-type: application/mercurial-exp-framing-0006\r\n 166 s> content-type: application/mercurial-exp-framing-0006\r\n
167 s> user-agent: test\r\n 167 s> user-agent: test\r\n
168 s> content-length: 29\r\n 168 s> content-length: 29\r\n
194 $ sendhttpv2peerverbose << EOF 194 $ sendhttpv2peerverbose << EOF
195 > command customreadonly 195 > command customreadonly
196 > EOF 196 > EOF
197 creating http peer for wire protocol version 2 197 creating http peer for wire protocol version 2
198 sending customreadonly command 198 sending customreadonly command
199 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 199 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
200 s> Accept-Encoding: identity\r\n 200 s> Accept-Encoding: identity\r\n
201 s> accept: application/mercurial-exp-framing-0006\r\n 201 s> accept: application/mercurial-exp-framing-0006\r\n
202 s> content-type: application/mercurial-exp-framing-0006\r\n 202 s> content-type: application/mercurial-exp-framing-0006\r\n
203 s> content-length: 65\r\n 203 s> content-length: 65\r\n
204 s> host: $LOCALIP:$HGPORT\r\n (glob) 204 s> host: $LOCALIP:$HGPORT\r\n (glob)
245 $ sendhttpraw << EOF 245 $ sendhttpraw << EOF
246 > httprequest GET api/$HTTPV2/rw/customreadonly 246 > httprequest GET api/$HTTPV2/rw/customreadonly
247 > user-agent: test 247 > user-agent: test
248 > EOF 248 > EOF
249 using raw connection to peer 249 using raw connection to peer
250 s> GET /api/exp-http-v2-0002/rw/customreadonly HTTP/1.1\r\n 250 s> GET /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
251 s> Accept-Encoding: identity\r\n 251 s> Accept-Encoding: identity\r\n
252 s> user-agent: test\r\n 252 s> user-agent: test\r\n
253 s> host: $LOCALIP:$HGPORT\r\n (glob) 253 s> host: $LOCALIP:$HGPORT\r\n (glob)
254 s> \r\n 254 s> \r\n
255 s> makefile('rb', None) 255 s> makefile('rb', None)
266 $ sendhttpraw << EOF 266 $ sendhttpraw << EOF
267 > httprequest GET api/$HTTPV2/rw/badcommand 267 > httprequest GET api/$HTTPV2/rw/badcommand
268 > user-agent: test 268 > user-agent: test
269 > EOF 269 > EOF
270 using raw connection to peer 270 using raw connection to peer
271 s> GET /api/exp-http-v2-0002/rw/badcommand HTTP/1.1\r\n 271 s> GET /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
272 s> Accept-Encoding: identity\r\n 272 s> Accept-Encoding: identity\r\n
273 s> user-agent: test\r\n 273 s> user-agent: test\r\n
274 s> host: $LOCALIP:$HGPORT\r\n (glob) 274 s> host: $LOCALIP:$HGPORT\r\n (glob)
275 s> \r\n 275 s> \r\n
276 s> makefile('rb', None) 276 s> makefile('rb', None)
287 $ sendhttpraw << EOF 287 $ sendhttpraw << EOF
288 > httprequest POST api/$HTTPV2/rw/customreadonly 288 > httprequest POST api/$HTTPV2/rw/customreadonly
289 > user-agent: test 289 > user-agent: test
290 > EOF 290 > EOF
291 using raw connection to peer 291 using raw connection to peer
292 s> POST /api/exp-http-v2-0002/rw/customreadonly HTTP/1.1\r\n 292 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
293 s> Accept-Encoding: identity\r\n 293 s> Accept-Encoding: identity\r\n
294 s> user-agent: test\r\n 294 s> user-agent: test\r\n
295 s> host: $LOCALIP:$HGPORT\r\n (glob) 295 s> host: $LOCALIP:$HGPORT\r\n (glob)
296 s> \r\n 296 s> \r\n
297 s> makefile('rb', None) 297 s> makefile('rb', None)
325 > accept: $MEDIATYPE 325 > accept: $MEDIATYPE
326 > content-type: $MEDIATYPE 326 > content-type: $MEDIATYPE
327 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'} 327 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
328 > EOF 328 > EOF
329 using raw connection to peer 329 using raw connection to peer
330 s> POST /api/exp-http-v2-0002/rw/customreadonly HTTP/1.1\r\n 330 s> POST /api/exp-http-v2-0003/rw/customreadonly HTTP/1.1\r\n
331 s> Accept-Encoding: identity\r\n 331 s> Accept-Encoding: identity\r\n
332 s> accept: application/mercurial-exp-framing-0006\r\n 332 s> accept: application/mercurial-exp-framing-0006\r\n
333 s> content-type: application/mercurial-exp-framing-0006\r\n 333 s> content-type: application/mercurial-exp-framing-0006\r\n
334 s> user-agent: test\r\n 334 s> user-agent: test\r\n
335 s> content-length: 29\r\n 335 s> content-length: 29\r\n
364 > httprequest POST api/$HTTPV2/rw/badcommand 364 > httprequest POST api/$HTTPV2/rw/badcommand
365 > user-agent: test 365 > user-agent: test
366 > accept: $MEDIATYPE 366 > accept: $MEDIATYPE
367 > EOF 367 > EOF
368 using raw connection to peer 368 using raw connection to peer
369 s> POST /api/exp-http-v2-0002/rw/badcommand HTTP/1.1\r\n 369 s> POST /api/exp-http-v2-0003/rw/badcommand HTTP/1.1\r\n
370 s> Accept-Encoding: identity\r\n 370 s> Accept-Encoding: identity\r\n
371 s> accept: application/mercurial-exp-framing-0006\r\n 371 s> accept: application/mercurial-exp-framing-0006\r\n
372 s> user-agent: test\r\n 372 s> user-agent: test\r\n
373 s> host: $LOCALIP:$HGPORT\r\n (glob) 373 s> host: $LOCALIP:$HGPORT\r\n (glob)
374 s> \r\n 374 s> \r\n
386 $ sendhttpraw << EOF 386 $ sendhttpraw << EOF
387 > httprequest POST api/$HTTPV2/ro/debugreflect 387 > httprequest POST api/$HTTPV2/ro/debugreflect
388 > user-agent: test 388 > user-agent: test
389 > EOF 389 > EOF
390 using raw connection to peer 390 using raw connection to peer
391 s> POST /api/exp-http-v2-0002/ro/debugreflect HTTP/1.1\r\n 391 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
392 s> Accept-Encoding: identity\r\n 392 s> Accept-Encoding: identity\r\n
393 s> user-agent: test\r\n 393 s> user-agent: test\r\n
394 s> host: $LOCALIP:$HGPORT\r\n (glob) 394 s> host: $LOCALIP:$HGPORT\r\n (glob)
395 s> \r\n 395 s> \r\n
396 s> makefile('rb', None) 396 s> makefile('rb', None)
426 > content-type: $MEDIATYPE 426 > content-type: $MEDIATYPE
427 > user-agent: test 427 > user-agent: test
428 > frame 1 1 stream-begin command-request new cbor:{b'name': b'command1', b'args': {b'foo': b'val1', b'bar1': b'val'}} 428 > frame 1 1 stream-begin command-request new cbor:{b'name': b'command1', b'args': {b'foo': b'val1', b'bar1': b'val'}}
429 > EOF 429 > EOF
430 using raw connection to peer 430 using raw connection to peer
431 s> POST /api/exp-http-v2-0002/ro/debugreflect HTTP/1.1\r\n 431 s> POST /api/exp-http-v2-0003/ro/debugreflect HTTP/1.1\r\n
432 s> Accept-Encoding: identity\r\n 432 s> Accept-Encoding: identity\r\n
433 s> accept: application/mercurial-exp-framing-0006\r\n 433 s> accept: application/mercurial-exp-framing-0006\r\n
434 s> content-type: application/mercurial-exp-framing-0006\r\n 434 s> content-type: application/mercurial-exp-framing-0006\r\n
435 s> user-agent: test\r\n 435 s> user-agent: test\r\n
436 s> content-length: 47\r\n 436 s> content-length: 47\r\n
457 > content-type: $MEDIATYPE 457 > content-type: $MEDIATYPE
458 > user-agent: test 458 > user-agent: test
459 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'} 459 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
460 > EOF 460 > EOF
461 using raw connection to peer 461 using raw connection to peer
462 s> POST /api/exp-http-v2-0002/ro/customreadonly HTTP/1.1\r\n 462 s> POST /api/exp-http-v2-0003/ro/customreadonly HTTP/1.1\r\n
463 s> Accept-Encoding: identity\r\n 463 s> Accept-Encoding: identity\r\n
464 s> accept: application/mercurial-exp-framing-0006\r\n 464 s> accept: application/mercurial-exp-framing-0006\r\n
465 s> content-type: application/mercurial-exp-framing-0006\r\n 465 s> content-type: application/mercurial-exp-framing-0006\r\n
466 s> user-agent: test\r\n 466 s> user-agent: test\r\n
467 s> content-length: 29\r\n 467 s> content-length: 29\r\n
499 > user-agent: test 499 > user-agent: test
500 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'} 500 > frame 1 1 stream-begin command-request new cbor:{b'name': b'customreadonly'}
501 > frame 3 1 0 command-request new cbor:{b'name': b'customreadonly'} 501 > frame 3 1 0 command-request new cbor:{b'name': b'customreadonly'}
502 > EOF 502 > EOF
503 using raw connection to peer 503 using raw connection to peer
504 s> POST /api/exp-http-v2-0002/ro/multirequest HTTP/1.1\r\n 504 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
505 s> Accept-Encoding: identity\r\n 505 s> Accept-Encoding: identity\r\n
506 s> *\r\n (glob) 506 s> *\r\n (glob)
507 s> *\r\n (glob) 507 s> *\r\n (glob)
508 s> user-agent: test\r\n 508 s> user-agent: test\r\n
509 s> content-length: 58\r\n 509 s> content-length: 58\r\n
552 > frame 3 1 0 command-request new|more \xa2Dargs\xa1Inamespace 552 > frame 3 1 0 command-request new|more \xa2Dargs\xa1Inamespace
553 > frame 3 1 0 command-request continuation JnamespacesDnameHlistkeys 553 > frame 3 1 0 command-request continuation JnamespacesDnameHlistkeys
554 > frame 1 1 0 command-request continuation IbookmarksDnameHlistkeys 554 > frame 1 1 0 command-request continuation IbookmarksDnameHlistkeys
555 > EOF 555 > EOF
556 using raw connection to peer 556 using raw connection to peer
557 s> POST /api/exp-http-v2-0002/ro/multirequest HTTP/1.1\r\n 557 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
558 s> Accept-Encoding: identity\r\n 558 s> Accept-Encoding: identity\r\n
559 s> accept: application/mercurial-exp-framing-0006\r\n 559 s> accept: application/mercurial-exp-framing-0006\r\n
560 s> content-type: application/mercurial-exp-framing-0006\r\n 560 s> content-type: application/mercurial-exp-framing-0006\r\n
561 s> user-agent: test\r\n 561 s> user-agent: test\r\n
562 s> content-length: 115\r\n 562 s> content-length: 115\r\n
617 > content-type: $MEDIATYPE 617 > content-type: $MEDIATYPE
618 > user-agent: test 618 > user-agent: test
619 > frame 1 1 stream-begin command-request new cbor:{b'name': b'pushkey'} 619 > frame 1 1 stream-begin command-request new cbor:{b'name': b'pushkey'}
620 > EOF 620 > EOF
621 using raw connection to peer 621 using raw connection to peer
622 s> POST /api/exp-http-v2-0002/ro/multirequest HTTP/1.1\r\n 622 s> POST /api/exp-http-v2-0003/ro/multirequest HTTP/1.1\r\n
623 s> Accept-Encoding: identity\r\n 623 s> Accept-Encoding: identity\r\n
624 s> accept: application/mercurial-exp-framing-0006\r\n 624 s> accept: application/mercurial-exp-framing-0006\r\n
625 s> content-type: application/mercurial-exp-framing-0006\r\n 625 s> content-type: application/mercurial-exp-framing-0006\r\n
626 s> user-agent: test\r\n 626 s> user-agent: test\r\n
627 s> content-length: 22\r\n 627 s> content-length: 22\r\n
643 > command heads 643 > command heads
644 > EOF 644 > EOF
645 creating http peer for wire protocol version 2 645 creating http peer for wire protocol version 2
646 sending heads command 646 sending heads command
647 wire protocol version 2 encoder referenced in config (badencoder) is not known; ignoring 647 wire protocol version 2 encoder referenced in config (badencoder) is not known; ignoring
648 s> POST /api/exp-http-v2-0002/ro/heads HTTP/1.1\r\n 648 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
649 s> Accept-Encoding: identity\r\n 649 s> Accept-Encoding: identity\r\n
650 s> accept: application/mercurial-exp-framing-0006\r\n 650 s> accept: application/mercurial-exp-framing-0006\r\n
651 s> content-type: application/mercurial-exp-framing-0006\r\n 651 s> content-type: application/mercurial-exp-framing-0006\r\n
652 s> content-length: 56\r\n 652 s> content-length: 56\r\n
653 s> host: $LOCALIP:$HGPORT\r\n (glob) 653 s> host: $LOCALIP:$HGPORT\r\n (glob)
692 $ hg --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF 692 $ hg --verbose debugwireproto --nologhandshake --peer http2 http://$LOCALIP:$HGPORT/ << EOF
693 > command heads 693 > command heads
694 > EOF 694 > EOF
695 creating http peer for wire protocol version 2 695 creating http peer for wire protocol version 2
696 sending heads command 696 sending heads command
697 s> POST /api/exp-http-v2-0002/ro/heads HTTP/1.1\r\n 697 s> POST /api/exp-http-v2-0003/ro/heads HTTP/1.1\r\n
698 s> Accept-Encoding: identity\r\n 698 s> Accept-Encoding: identity\r\n
699 s> accept: application/mercurial-exp-framing-0006\r\n 699 s> accept: application/mercurial-exp-framing-0006\r\n
700 s> content-type: application/mercurial-exp-framing-0006\r\n 700 s> content-type: application/mercurial-exp-framing-0006\r\n
701 s> content-length: 70\r\n 701 s> content-length: 70\r\n
702 s> host: $LOCALIP:$HGPORT\r\n (glob) 702 s> host: $LOCALIP:$HGPORT\r\n (glob)