[PATCH 11 of 12 V3] getbundle: add support for 'bookmarks' boolean argument

Boris Feld boris.feld at octobus.net
Mon Nov 20 11:52:02 EST 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1508246837 -7200
#      Tue Oct 17 15:27:17 2017 +0200
# Node ID c80059749ef79fab71bc041d464978608a2ad774
# Parent  7e610585998e3eff1d0498a6ce024350bb04fc23
# EXP-Topic b2.bookmarks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r c80059749ef7
getbundle: add support for 'bookmarks' boolean argument

This new argument requests a 'bookmarks' part from the server. It is meant to
be used instead of the "listkeys" request.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1750,6 +1750,19 @@ def _getbundlechangegrouppart(bundler, r
         if 'treemanifest' in repo.requirements:
             part.addparam('treemanifest', '1')
 
+ at getbundle2partsgenerator('bookmarks')
+def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
+                              b2caps=None, **kwargs):
+    """add a bookmark part to the requested bundle"""
+    if not kwargs.get('bookmarks', False):
+        return
+    if 'bookmarks' not in b2caps:
+        raise ValueError(_('no common bookmarks exchange method'))
+    books  = bookmod.listbinbookmarks(repo)
+    data = bookmod.binaryencode(books)
+    if data:
+        bundler.newpart('bookmarks', data=data)
+
 @getbundle2partsgenerator('listkeys')
 def _getbundlelistkeysparts(bundler, repo, source, bundlecaps=None,
                             b2caps=None, **kwargs):
diff --git a/mercurial/help/internals/wireprotocol.txt b/mercurial/help/internals/wireprotocol.txt
--- a/mercurial/help/internals/wireprotocol.txt
+++ b/mercurial/help/internals/wireprotocol.txt
@@ -731,6 +731,8 @@ cg
 cbattempted
    Boolean indicating whether the client attempted to use the *clone bundles*
    feature before performing this request.
+bookmarks
+   Boolean indicating whether bookmark data is requested.
 phases
    Boolean indicating whether phases data is requested.
 
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -205,6 +205,7 @@ def encodebatchcmds(req):
 # :scsv:  list of comma-separated values return as set
 # :plain: string with no transformation needed.
 gboptsmap = {'heads':  'nodes',
+             'bookmarks': 'boolean',
              'common': 'nodes',
              'obsmarkers': 'boolean',
              'phases': 'boolean',


More information about the Mercurial-devel mailing list