Patchwork [13,of,15] getbundle: add support for 'bookmarks' boolean argument

login
register
mail settings
Submitter Boris Feld
Date Oct. 18, 2017, 4:10 p.m.
Message ID <bfc5187907ca1ddda659.1508343005@FB>
Download mbox | patch
Permalink /patch/25196/
State Accepted
Headers show

Comments

Boris Feld - Oct. 18, 2017, 4:10 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1508246837 -7200
#      Tue Oct 17 15:27:17 2017 +0200
# Node ID bfc5187907ca1ddda6594eeb6904a3d3d185c22b
# Parent  621cfc2d79d7a541503a369b4576b6d56cee2777
# EXP-Topic b2.bookmarks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r bfc5187907ca
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.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1748,6 +1748,18 @@ 
         if 'treemanifest' in repo.requirements:
             part.addparam('treemanifest', '1')
 
+@getbundle2partsgenerator('bookmarks')
+def _getbundlebookmarkpart(bundler, repo, source, bundlecaps=None,
+                              b2caps=None, **kwargs):
+    """add a bookmark part to the requested bundle"""
+    if kwargs.get('bookmarks', False):
+        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/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -205,6 +205,7 @@ 
 # :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',