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

login
register
mail settings
Submitter Stanislau Hlebik
Date Nov. 13, 2016, 10:30 a.m.
Message ID <ffa31155703b725b20d6.1479033012@dev1918.lla1.facebook.com>
Download mbox | patch
Permalink /patch/17533/
State Changes Requested
Headers show

Comments

Stanislau Hlebik - Nov. 13, 2016, 10:30 a.m.
# HG changeset patch
# User Stanislau Hlebik <stash@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.

Patch

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).