Mercurial > public > mercurial-scm > hg
comparison mercurial/wireprotov2server.py @ 39634:9dffa99f9158
wireprotov2: add bookmarks to "changesetdata" command
Like we did for phases, we want to emit bookmarks data attached
to each changeset.
The approach here is very similar to phases: we emit bookmarks
data inline with requested revision data. But we emit
records for nodes that weren't requested as well so consumers have
access to the full set of defined bookmarks.
Differential Revision: https://phab.mercurial-scm.org/D4485
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 23 Aug 2018 18:14:19 -0700 |
parents | c1aacb0d76ff |
children | 399ddd3227a4 |
comparison
equal
deleted
inserted
replaced
39633:ff2de4f2eb3c | 39634:9dffa99f9158 |
---|---|
531 yield { | 531 yield { |
532 b'node': node, | 532 b'node': node, |
533 b'phase': b'public' if publishing else repo[node].phasestr() | 533 b'phase': b'public' if publishing else repo[node].phasestr() |
534 } | 534 } |
535 | 535 |
536 nodebookmarks = {} | |
537 for mark, node in repo._bookmarks.items(): | |
538 nodebookmarks.setdefault(node, set()).add(mark) | |
539 | |
536 # It is already topologically sorted by revision number. | 540 # It is already topologically sorted by revision number. |
537 for node in outgoing: | 541 for node in outgoing: |
538 d = { | 542 d = { |
539 b'node': node, | 543 b'node': node, |
540 } | 544 } |
547 d[b'phase'] = b'public' | 551 d[b'phase'] = b'public' |
548 else: | 552 else: |
549 ctx = repo[node] | 553 ctx = repo[node] |
550 d[b'phase'] = ctx.phasestr() | 554 d[b'phase'] = ctx.phasestr() |
551 | 555 |
556 if b'bookmarks' in fields and node in nodebookmarks: | |
557 d[b'bookmarks'] = sorted(nodebookmarks[node]) | |
558 del nodebookmarks[node] | |
559 | |
552 revisiondata = None | 560 revisiondata = None |
553 | 561 |
554 if b'revision' in fields: | 562 if b'revision' in fields: |
555 revisiondata = cl.revision(node, raw=True) | 563 revisiondata = cl.revision(node, raw=True) |
556 d[b'revisionsize'] = len(revisiondata) | 564 d[b'revisionsize'] = len(revisiondata) |
557 | 565 |
558 yield d | 566 yield d |
559 | 567 |
560 if revisiondata is not None: | 568 if revisiondata is not None: |
561 yield revisiondata | 569 yield revisiondata |
570 | |
571 # If requested, send bookmarks from nodes that didn't have revision | |
572 # data sent so receiver is aware of any bookmark updates. | |
573 if b'bookmarks' in fields: | |
574 for node, marks in sorted(nodebookmarks.iteritems()): | |
575 yield { | |
576 b'node': node, | |
577 b'bookmarks': sorted(marks), | |
578 } | |
562 | 579 |
563 @wireprotocommand('heads', | 580 @wireprotocommand('heads', |
564 args={ | 581 args={ |
565 'publiconly': False, | 582 'publiconly': False, |
566 }, | 583 }, |