Patchwork [03,of,10,V8] exchange: add `_getbookmarks()` function

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 12, 2016, 8:19 p.m.
Message ID <cf754de559217f5965d1.1478981993@dev1918.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17519/
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 cf754de559217f5965d1101c4591689d9924bddc
# Parent  13b3e16c68d303a523550980d7739bb676420851
exchange: add `_getbookmarks()` function

This function will be used to generate bookmarks bundle2 part.
It is a separate function in order to make it easy to overwrite it
in extensions. Passing `kwargs` to the function makes it easy to
add new parameters in extensions.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1666,6 +1666,17 @@ 
     if chunks:
         bundler.newpart('hgtagsfnodes', data=''.join(chunks))
 
+def _getbookmarks(repo, **kwargs):
+    """Returns bookmark to node mapping.
+
+    This function is primarily used to generate `bookmarks` bundle2 part.
+    It is a separate function in order to make it easy to wrap it
+    in extensions. Passing `kwargs` to the function makes it easy to
+    add new parameters in extensions.
+    """
+
+    return dict(bookmod.listbookmarks(repo))
+
 def check_heads(repo, their_heads, context):
     """check if the heads of a repo have been modified