[PATCH 01 of 10 V9] bookmarks: introduce listbinbookmarks()

Stanislau Hlebik stash at fb.com
Sun Nov 13 10:30:12 UTC 2016


# HG changeset patch
# User Stanislau Hlebik <stash at fb.com>
# Date 1479032036 28800
#      Sun Nov 13 02:13:56 2016 -0800
# Branch stable
# Node ID ffa31155703b725b20d67f379bea4de7c56379fe
# Parent  b9f7b0c10027764cee77f9c6d61877fcffea837f
bookmarks: introduce listbinbookmarks()

`bookmarks` bundle2 part will work with binary nodes. To avoid unnecessary
conversions between binary and hex nodes let's add `listbinbookmarks()` that
returns binary nodes. For now this function is a copy-paste of
listbookmarks(). In the next patch this copy-paste will be removed.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -284,6 +284,17 @@
             lockmod.release(tr, lock)
     return update
 
+def listbinbookmarks(repo):
+    # We may try to list bookmarks on a repo type that does not
+    # support it (e.g., statichttprepository).
+    marks = getattr(repo, '_bookmarks', {})
+
+    hasnode = repo.changelog.hasnode
+    for k, v in marks.iteritems():
+        # don't expose local divergent bookmarks
+        if hasnode(v) and ('@' not in k or k.endswith('@')):
+            yield k, v
+
 def listbookmarks(repo):
     # We may try to list bookmarks on a repo type that does not
     # support it (e.g., statichttprepository).


More information about the Mercurial-devel mailing list