##// END OF EJS Templates
wireprotov2: add phases to "changesetdata" command...
Gregory Szorc -
r39668:c1aacb0d default
parent child Browse files
Show More
@@ -113,6 +113,9 b' fields'
113 parents
113 parents
114 Parent revisions.
114 Parent revisions.
115
115
116 phase
117 The phase state of a revision.
118
116 revision
119 revision
117 The raw, revision data for the changelog entry. The hash of this data
120 The raw, revision data for the changelog entry. The hash of this data
118 will match the revision's node value.
121 will match the revision's node value.
@@ -126,7 +129,8 b' This map has the following bytestring ke'
126
129
127 totalitems
130 totalitems
128 (unsigned integer) Total number of changelog revisions whose data is being
131 (unsigned integer) Total number of changelog revisions whose data is being
129 transferred.
132 transferred. This maps to the set of revisions in the requested node
133 range, not the total number of records that follow (see below for why).
130
134
131 Following the map header is a series of 0 or more CBOR values. If values
135 Following the map header is a series of 0 or more CBOR values. If values
132 are present, the first value will always be a map describing a single changeset
136 are present, the first value will always be a map describing a single changeset
@@ -144,6 +148,11 b' parents (optional)'
144 (array of bytestrings) The nodes representing the parent revisions of this
148 (array of bytestrings) The nodes representing the parent revisions of this
145 revision. Only present if ``parents`` data is being requested.
149 revision. Only present if ``parents`` data is being requested.
146
150
151 phase (optional)
152 (bytestring) The phase that a revision is in. Recognized values are
153 ``secret``, ``draft``, and ``public``. Only present if ``phase`` data
154 is being requested.
155
147 revisionsize (optional)
156 revisionsize (optional)
148 (unsigned integer) Indicates the size of raw revision data that follows this
157 (unsigned integer) Indicates the size of raw revision data that follows this
149 map. The following data contains a serialized form of the changeset data,
158 map. The following data contains a serialized form of the changeset data,
@@ -160,10 +169,19 b' If nodes are requested via ``nodes``, th'
160
169
161 Nodes from ``nodes`` are emitted before nodes from ``noderange``.
170 Nodes from ``nodes`` are emitted before nodes from ``noderange``.
162
171
172 The set of changeset revisions emitted may not match the exact set of
173 changesets requested. Furthermore, the set of keys present on each
174 map may vary. This is to facilitate emitting changeset updates as well
175 as new revisions.
176
177 For example, if the request wants ``phase`` and ``revision`` data,
178 the response may contain entries for each changeset in the common nodes
179 set with the ``phase`` key and without the ``revision`` key in order
180 to reflect a phase-only update.
181
163 TODO support different revision selection mechanisms (e.g. non-public, specific
182 TODO support different revision selection mechanisms (e.g. non-public, specific
164 revisions)
183 revisions)
165 TODO support different hash "namespaces" for revisions (e.g. sha-1 versus other)
184 TODO support different hash "namespaces" for revisions (e.g. sha-1 versus other)
166 TODO support emitting phases data
167 TODO support emitting bookmarks data
185 TODO support emitting bookmarks data
168 TODO support emitting obsolescence data
186 TODO support emitting obsolescence data
169 TODO support filtering based on relevant paths (narrow clone)
187 TODO support filtering based on relevant paths (narrow clone)
@@ -511,6 +511,7 b' def changesetdata(repo, proto, noderange'
511 # list.
511 # list.
512
512
513 seen.clear()
513 seen.clear()
514 publishing = repo.publishing()
514
515
515 if outgoing:
516 if outgoing:
516 repo.hook('preoutgoing', throw=True, source='serve')
517 repo.hook('preoutgoing', throw=True, source='serve')
@@ -519,6 +520,19 b' def changesetdata(repo, proto, noderange'
519 b'totalitems': len(outgoing),
520 b'totalitems': len(outgoing),
520 }
521 }
521
522
523 # The phases of nodes already transferred to the client may have changed
524 # since the client last requested data. We send phase-only records
525 # for these revisions, if requested.
526 if b'phase' in fields and noderange is not None:
527 # TODO skip nodes whose phase will be reflected by a node in the
528 # outgoing set. This is purely an optimization to reduce data
529 # size.
530 for node in noderange[0]:
531 yield {
532 b'node': node,
533 b'phase': b'public' if publishing else repo[node].phasestr()
534 }
535
522 # It is already topologically sorted by revision number.
536 # It is already topologically sorted by revision number.
523 for node in outgoing:
537 for node in outgoing:
524 d = {
538 d = {
@@ -528,6 +542,13 b' def changesetdata(repo, proto, noderange'
528 if b'parents' in fields:
542 if b'parents' in fields:
529 d[b'parents'] = cl.parents(node)
543 d[b'parents'] = cl.parents(node)
530
544
545 if b'phase' in fields:
546 if publishing:
547 d[b'phase'] = b'public'
548 else:
549 ctx = repo[node]
550 d[b'phase'] = ctx.phasestr()
551
531 revisiondata = None
552 revisiondata = None
532
553
533 if b'revision' in fields:
554 if b'revision' in fields:
@@ -3,6 +3,10 b''
3 $ hg init server
3 $ hg init server
4 $ enablehttpv2 server
4 $ enablehttpv2 server
5 $ cd server
5 $ cd server
6 $ cat >> .hg/hgrc << EOF
7 > [phases]
8 > publish = false
9 > EOF
6 $ echo a0 > a
10 $ echo a0 > a
7 $ echo b0 > b
11 $ echo b0 > b
8
12
@@ -13,6 +17,7 b''
13 $ hg commit -m 'commit 1'
17 $ hg commit -m 'commit 1'
14 $ echo b2 > b
18 $ echo b2 > b
15 $ hg commit -m 'commit 2'
19 $ hg commit -m 'commit 2'
20 $ hg phase --public -r .
16
21
17 $ hg -q up -r 0
22 $ hg -q up -r 0
18 $ echo a2 > a
23 $ echo a2 > a
@@ -365,6 +370,57 b' Parents data is transferred upon request'
365 }
370 }
366 ]
371 ]
367
372
373 Phase data is transferred upon request
374
375 $ sendhttpv2peer << EOF
376 > command changesetdata
377 > fields eval:[b'phase']
378 > nodes eval:[b'\x0b\xb8\xad\x89\x4a\x15\xb1\x53\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f\x2a\x4b\x28\xdd']
379 > EOF
380 creating http peer for wire protocol version 2
381 sending changesetdata command
382 s> POST /api/exp-http-v2-0001/ro/changesetdata HTTP/1.1\r\n
383 s> Accept-Encoding: identity\r\n
384 s> accept: application/mercurial-exp-framing-0005\r\n
385 s> content-type: application/mercurial-exp-framing-0005\r\n
386 s> content-length: 76\r\n
387 s> host: $LOCALIP:$HGPORT\r\n (glob)
388 s> user-agent: Mercurial debugwireproto\r\n
389 s> \r\n
390 s> D\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2Ffields\x81EphaseEnodes\x81T\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xddDnameMchangesetdata
391 s> makefile('rb', None)
392 s> HTTP/1.1 200 OK\r\n
393 s> Server: testing stub value\r\n
394 s> Date: $HTTP_DATE$\r\n
395 s> Content-Type: application/mercurial-exp-framing-0005\r\n
396 s> Transfer-Encoding: chunked\r\n
397 s> \r\n
398 s> 13\r\n
399 s> \x0b\x00\x00\x01\x00\x02\x011
400 s> \xa1FstatusBok
401 s> \r\n
402 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
403 s> 3d\r\n
404 s> 5\x00\x00\x01\x00\x02\x001
405 s> \xa1Jtotalitems\x01\xa2DnodeT\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xddEphaseFpublic
406 s> \r\n
407 received frame(size=53; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
408 s> 8\r\n
409 s> \x00\x00\x00\x01\x00\x02\x002
410 s> \r\n
411 s> 0\r\n
412 s> \r\n
413 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
414 response: gen[
415 {
416 b'totalitems': 1
417 },
418 {
419 b'node': b'\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xdd',
420 b'phase': b'public'
421 }
422 ]
423
368 Revision data is transferred upon request
424 Revision data is transferred upon request
369
425
370 $ sendhttpv2peer << EOF
426 $ sendhttpv2peer << EOF
@@ -483,4 +539,101 b' Multiple fields can be transferred'
483 b'1b74476799ec8318045db759b1b4bcc9b839d0aa\ntest\n0 0\na\n\ncommit 3'
539 b'1b74476799ec8318045db759b1b4bcc9b839d0aa\ntest\n0 0\na\n\ncommit 3'
484 ]
540 ]
485
541
542 Base nodes have just their metadata (e.g. phase) transferred
543
544 $ sendhttpv2peer << EOF
545 > command changesetdata
546 > fields eval:[b'phase', b'parents', b'revision']
547 > noderange eval:[[b'\x33\x90\xef\x85\x00\x73\xfb\xc2\xf0\xdf\xff\x22\x44\x34\x2c\x8e\x92\x29\x01\x3a'], [b'\x0b\xb8\xad\x89\x4a\x15\xb1\x53\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f\x2a\x4b\x28\xdd', b'\xea\xe5\xf8\x2c\x2e\x62\x23\x68\xd2\x7d\xae\xcb\x76\xb7\xe3\x93\xd0\xf2\x42\x11']]
548 > EOF
549 creating http peer for wire protocol version 2
550 sending changesetdata command
551 s> POST /api/exp-http-v2-0001/ro/changesetdata HTTP/1.1\r\n
552 s> Accept-Encoding: identity\r\n
553 s> accept: application/mercurial-exp-framing-0005\r\n
554 s> content-type: application/mercurial-exp-framing-0005\r\n
555 s> content-length: 141\r\n
556 s> host: $LOCALIP:$HGPORT\r\n (glob)
557 s> user-agent: Mercurial debugwireproto\r\n
558 s> \r\n
559 s> \x85\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa2Ffields\x83EphaseGparentsHrevisionInoderange\x82\x81T3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:\x82T\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xddT\xea\xe5\xf8,.b#h\xd2}\xae\xcbv\xb7\xe3\x93\xd0\xf2B\x11DnameMchangesetdata
560 s> makefile('rb', None)
561 s> HTTP/1.1 200 OK\r\n
562 s> Server: testing stub value\r\n
563 s> Date: $HTTP_DATE$\r\n
564 s> Content-Type: application/mercurial-exp-framing-0005\r\n
565 s> Transfer-Encoding: chunked\r\n
566 s> \r\n
567 s> 13\r\n
568 s> \x0b\x00\x00\x01\x00\x02\x011
569 s> \xa1FstatusBok
570 s> \r\n
571 received frame(size=11; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=continuation)
572 s> 239\r\n
573 s> 1\x02\x00\x01\x00\x02\x001
574 s> \xa1Jtotalitems\x03\xa2DnodeT3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:EphaseFpublic\xa4DnodeTu\x92\x91~\x1c>\x82g|\xb0\xa4\xbcq\\\xa2]\xd1-(\xc1Gparents\x82T3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00EphaseFpublicLrevisionsize\x18?X?7f144aea0ba742713887b564d57e9d12f12ff382\n
575 s> test\n
576 s> 0 0\n
577 s> a\n
578 s> b\n
579 s> \n
580 s> commit 1\xa4DnodeT\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xddGparents\x82Tu\x92\x91~\x1c>\x82g|\xb0\xa4\xbcq\\\xa2]\xd1-(\xc1T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00EphaseFpublicLrevisionsize\x18=X=37f0a2d1c28ffe4b879109a7d1bbf8f07b3c763b\n
581 s> test\n
582 s> 0 0\n
583 s> b\n
584 s> \n
585 s> commit 2\xa4DnodeT\xea\xe5\xf8,.b#h\xd2}\xae\xcbv\xb7\xe3\x93\xd0\xf2B\x11Gparents\x82T3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:T\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00EphaseEdraftLrevisionsize\x18=X=1b74476799ec8318045db759b1b4bcc9b839d0aa\n
586 s> test\n
587 s> 0 0\n
588 s> a\n
589 s> \n
590 s> commit 3
591 s> \r\n
592 received frame(size=561; request=1; stream=2; streamflags=; type=command-response; flags=continuation)
593 s> 8\r\n
594 s> \x00\x00\x00\x01\x00\x02\x002
595 s> \r\n
596 s> 0\r\n
597 s> \r\n
598 received frame(size=0; request=1; stream=2; streamflags=; type=command-response; flags=eos)
599 response: gen[
600 {
601 b'totalitems': 3
602 },
603 {
604 b'node': b'3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
605 b'phase': b'public'
606 },
607 {
608 b'node': b'u\x92\x91~\x1c>\x82g|\xb0\xa4\xbcq\\\xa2]\xd1-(\xc1',
609 b'parents': [
610 b'3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
611 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
612 ],
613 b'phase': b'public',
614 b'revisionsize': 63
615 },
616 b'7f144aea0ba742713887b564d57e9d12f12ff382\ntest\n0 0\na\nb\n\ncommit 1',
617 {
618 b'node': b'\x0b\xb8\xad\x89J\x15\xb1S\x80\xb2\xa2\xa5\xb1\x83\xe2\x0f*K(\xdd',
619 b'parents': [
620 b'u\x92\x91~\x1c>\x82g|\xb0\xa4\xbcq\\\xa2]\xd1-(\xc1',
621 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
622 ],
623 b'phase': b'public',
624 b'revisionsize': 61
625 },
626 b'37f0a2d1c28ffe4b879109a7d1bbf8f07b3c763b\ntest\n0 0\nb\n\ncommit 2',
627 {
628 b'node': b'\xea\xe5\xf8,.b#h\xd2}\xae\xcbv\xb7\xe3\x93\xd0\xf2B\x11',
629 b'parents': [
630 b'3\x90\xef\x85\x00s\xfb\xc2\xf0\xdf\xff"D4,\x8e\x92)\x01:',
631 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
632 ],
633 b'phase': b'draft',
634 b'revisionsize': 61
635 },
636 b'1b74476799ec8318045db759b1b4bcc9b839d0aa\ntest\n0 0\na\n\ncommit 3'
637 ]
638
486 $ cat error.log
639 $ cat error.log
General Comments 0
You need to be logged in to leave comments. Login now