# HG changeset patch # User Stanislau Hlebik <st...@fb.com> # Date 1478980589 28800 # Sat Nov 12 11:56:29 2016 -0800 # Branch stable # Node ID 13b3e16c68d303a523550980d7739bb676420851 # Parent fe9e78883230a875ae7acf6c7a5b324c1d9016f5 bookmarks: introduce listbookmarks()
`bookmarks` bundle2 part will work with binary nodes. To avoid unnecessary conversions between binary and hex nodes let's add `listbookmarks()` that returns binary nodes. diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py --- a/mercurial/bookmarks.py +++ b/mercurial/bookmarks.py @@ -284,17 +284,21 @@ lockmod.release(tr, lock) return update -def listhexbookmarks(repo): +def listbookmarks(repo): # We may try to list bookmarks on a repo type that does not # support it (e.g., statichttprepository). marks = getattr(repo, '_bookmarks', {}) - d = {} 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('@')): - d[k] = hex(v) + yield k, v + +def listhexbookmarks(repo): + d = {} + for book, node in listbookmarks(repo): + d[book] = hex(node) return d def pushbookmark(repo, key, old, new): _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel