Patchwork [5,of,8,V12] exchange: getbundle `bookmarks` part generator

login
register
mail settings
Submitter Stanislau Hlebik
Date Dec. 1, 2016, 6:07 p.m.
Message ID <b08e4f9ed873bb9b6bd8.1480615644@devvm957.lla2.facebook.com>
Download mbox | patch
Permalink /patch/17808/
State Superseded
Headers show

Comments

Stanislau Hlebik - Dec. 1, 2016, 6:07 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1479807361 28800
#      Tue Nov 22 01:36:01 2016 -0800
# Node ID b08e4f9ed873bb9b6bd8e170401a150f9b094bfd
# Parent  49d598a6db4b0fa63b7a30b55899caa0fa1f9c99
exchange: getbundle `bookmarks` part generator

This generator will be used during pull operation.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1675,6 +1675,21 @@ 
     if chunks:
         bundler.newpart('hgtagsfnodes', data=''.join(chunks))
 
+@getbundle2partsgenerator('bookmarks')
+def _getbundlebookmarkspart(bundler, repo, source, bundlecaps=None,
+                            b2caps=None, heads=None, common=None,
+                            **kwargs):
+    if not kwargs.get('bookmarks'):
+        return
+    if 'bookmarks' not in b2caps:
+        raise ValueError(
+            _('bookmarks are requested but client is not capable '
+              'of receiving it'))
+
+    bookmarks = _getbookmarks(repo, **kwargs)
+    encodedbookmarks = bookmod.encodebookmarks(bookmarks)
+    bundler.newpart('bookmarks', data=encodedbookmarks)
+
 def _getbookmarks(repo, **kwargs):
     """Returns bookmark to node mapping.
 
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -212,7 +212,9 @@ 
              'bundlecaps': 'scsv',
              'listkeys': 'csv',
              'cg': 'boolean',
-             'cbattempted': 'boolean'}
+             'cbattempted': 'boolean',
+             'bookmarks': 'boolean',
+            }
 
 # client side