Patchwork [04,of,12,V3] bookmark: introduce a 'bookmarks' part

login
register
mail settings
Submitter Boris Feld
Date Nov. 20, 2017, 4:51 p.m.
Message ID <17f26502af06258ceadc.1511196715@FB>
Download mbox | patch
Permalink /patch/25655/
State Accepted
Headers show

Comments

Boris Feld - Nov. 20, 2017, 4:51 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1508083331 -7200
#      Sun Oct 15 18:02:11 2017 +0200
# Node ID 17f26502af06258ceadceffc6e2ff445b4b18e7d
# Parent  fc0b863b8b38e7b4dd6270427c581f8992dfc61c
# EXP-Topic b2.bookmarks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 17f26502af06
bookmark: introduce a 'bookmarks' part

This part can carry and apply bookmarks information. We start with adding the
core behavior of the part. In its current form, the part is only suitable for
push since it plain update the bookmark without consideration for the local
state. Support of the behavior needed for pulling will be added in later
changesets.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1892,6 +1892,21 @@  def handlepushkey(op, inpart):
                 kwargs[key] = inpart.params[key]
         raise error.PushkeyFailed(partid=str(inpart.id), **kwargs)
 
+@parthandler('bookmarks')
+def handlebookmark(op, inpart):
+    """transmit bookmark information
+
+    The part contains binary encoded bookmark information. The bookmark
+    information is applied as is to the unbundling repository. Make sure a
+    'check:bookmarks' part is issued earlier to check for race condition in
+    such update.
+
+    This behavior is suitable for pushing. Semantic adjustment will be needed
+    for pull.
+    """
+    changes = bookmarks.binarydecode(inpart)
+    op.repo._bookmarks.applychanges(op.repo, op.gettransaction(), changes)
+
 @parthandler('phase-heads')
 def handlephases(op, inpart):
     """apply phases from bundle part to repo"""