Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchangev2.py @ 39651:349482d726ee
exchangev2: fetch and apply bookmarks
This is pretty similar to phases data. We collect bookmarks data
as we process records. Then at the end we make a call to the
bookmarks subsystem to reflect the remote's bookmarks.
Like phases, the code for handling bookmarks is vastly simpler
than the previous wire protocol code because the server always
transfers the full set of bookmarks when bookmarks are requested.
We don't have to keep track of whether we requested bookmarks or
not.
Differential Revision: https://phab.mercurial-scm.org/D4486
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 29 Aug 2018 17:03:19 -0700 |
parents | ff2de4f2eb3c |
children | 399ddd3227a4 |
line wrap: on
line diff
--- a/mercurial/exchangev2.py Thu Aug 23 18:14:19 2018 -0700 +++ b/mercurial/exchangev2.py Wed Aug 29 17:03:19 2018 -0700 @@ -15,6 +15,7 @@ short, ) from . import ( + bookmarks, mdiff, phases, pycompat, @@ -51,6 +52,11 @@ phases.advanceboundary(repo, tr, phases.phasenames.index(phase), csetres['nodesbyphase'][phase]) + # Write bookmark updates. + bookmarks.updatefromremote(repo.ui, repo, csetres['bookmarks'], + remote.url(), pullop.gettransaction, + explicit=pullop.explicitbookmarks) + def _pullchangesetdiscovery(repo, remote, heads, abortwhenunrelated=True): """Determine which changesets need to be pulled.""" @@ -91,7 +97,7 @@ with remote.commandexecutor() as e: objs = e.callcommand(b'changesetdata', { b'noderange': [sorted(common), sorted(remoteheads)], - b'fields': {b'parents', b'phase', b'revision'}, + b'fields': {b'bookmarks', b'parents', b'phase', b'revision'}, }).result() # The context manager waits on all response data when exiting. So @@ -124,6 +130,7 @@ progress.increment() nodesbyphase = {phase: set() for phase in phases.phasenames} + remotebookmarks = {} # addgroup() expects a 7-tuple describing revisions. This normalizes # the wire data to that format. @@ -137,6 +144,9 @@ if b'phase' in cset: nodesbyphase[cset[b'phase']].add(node) + for mark in cset.get(b'bookmarks', []): + remotebookmarks[mark] = node + # Some entries might only be metadata only updates. if b'revisionsize' not in cset: continue @@ -164,4 +174,5 @@ return { 'added': added, 'nodesbyphase': nodesbyphase, + 'bookmarks': remotebookmarks, }