Patchwork [07,of,10,V8] exchange: getbundle `bookmarks` part generator

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 12, 2016, 8:19 p.m.
Message ID <7bd99f5871d67df64e60.1478981997@dev1918.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17523/
State Superseded
Headers show

Comments

Stanislau Hlebik - Nov. 12, 2016, 8:19 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1478980606 28800
#      Sat Nov 12 11:56:46 2016 -0800
# Branch stable
# Node ID 7bd99f5871d67df64e60174f2c349bc088a584f6
# Parent  f8a24164d9190f457ff5cd5089b8879c71ec801f
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
@@ -1680,6 +1680,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
@@ -228,7 +228,9 @@ 
              'bundlecaps': 'scsv',
              'listkeys': 'csv',
              'cg': 'boolean',
-             'cbattempted': 'boolean'}
+             'cbattempted': 'boolean',
+             'bookmarks': 'boolean',
+            }
 
 # client side