bookmarks: introduce listbinbookmarks()
authorStanislau Hlebik <stash@fb.com>
Thu, 17 Nov 2016 00:59:41 -0800
changeset 30481 0a3b11a7489a
parent 30480 b0a8337ba9af
child 30482 55ec13c82ea0
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.
mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Mon Nov 21 16:22:26 2016 -0800
+++ b/mercurial/bookmarks.py	Thu Nov 17 00:59:41 2016 -0800
@@ -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).