[PATCH 01 of 10 V10] bookmarks: introduce listbinbookmarks()
Stanislau Hlebik
stash at fb.com
Sun Nov 20 12:13:54 UTC 2016
# HG changeset patch
# User Stanislau Hlebik <stash at fb.com>
# Date 1479373181 28800
# Thu Nov 17 00:59:41 2016 -0800
# Node ID a3159f73e59868f8ae0993cc91277142aaa10536
# Parent 854190becacb8abecddddbf5c18a777b02bbc045
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