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

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 20, 2016, 12:13 p.m.
Message ID <4e782ccf84f8fee96963.1479644036@dev1918.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17642/
State Accepted
Headers show

Comments

Stanislau Hlebik - Nov. 20, 2016, 12:13 p.m.
# HG changeset patch
# User Stanislau Hlebik <stash@fb.com>
# Date 1479373181 28800
#      Thu Nov 17 00:59:41 2016 -0800
# Node ID 4e782ccf84f8fee96963f09439f7da7202c37775
# Parent  54b24eb2eac7c181f9fd15423fd05218a6a11186
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.listbinbookmarks(repo))
+
 def check_heads(repo, their_heads, context):
     """check if the heads of a repo have been modified