Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotov2server.py @ 39650: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 |
line wrap: on
line diff
--- a/mercurial/wireprotov2server.py Wed Sep 12 10:01:58 2018 -0700 +++ b/mercurial/wireprotov2server.py Thu Aug 23 18:14:19 2018 -0700 @@ -533,6 +533,10 @@ b'phase': b'public' if publishing else repo[node].phasestr() } + nodebookmarks = {} + for mark, node in repo._bookmarks.items(): + nodebookmarks.setdefault(node, set()).add(mark) + # It is already topologically sorted by revision number. for node in outgoing: d = { @@ -549,6 +553,10 @@ ctx = repo[node] d[b'phase'] = ctx.phasestr() + if b'bookmarks' in fields and node in nodebookmarks: + d[b'bookmarks'] = sorted(nodebookmarks[node]) + del nodebookmarks[node] + revisiondata = None if b'revision' in fields: @@ -560,6 +568,15 @@ if revisiondata is not None: yield revisiondata + # If requested, send bookmarks from nodes that didn't have revision + # data sent so receiver is aware of any bookmark updates. + if b'bookmarks' in fields: + for node, marks in sorted(nodebookmarks.iteritems()): + yield { + b'node': node, + b'bookmarks': sorted(marks), + } + @wireprotocommand('heads', args={ 'publiconly': False,