Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bookmarks.py @ 39769:b05b4b91de3d
bookmarks: add explicit option to list bookmarks of the given names
This is a generalized form of the --active option.
A redundant sorted() call is removed. There was no point to update dict items
in lexicographical order.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Sep 2018 12:44:23 +0900 |
parents | 25cc5616adc9 |
children | 876494fd967d |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Sat Sep 15 12:34:13 2018 +0900 +++ b/mercurial/bookmarks.py Sat Sep 15 12:44:23 2018 +0900 @@ -936,21 +936,23 @@ fm.data(active=(activebookmarklabel in label)) fm.plain('\n') -def printbookmarks(ui, repo, fm): +def printbookmarks(ui, repo, fm, names=None): """print bookmarks by the given formatter Provides a way for extensions to control how bookmarks are printed. """ marks = repo._bookmarks bmarks = {} - for bmark, n in sorted(marks.iteritems()): + for bmark in (names or marks): + if bmark not in marks: + raise error.Abort(_("bookmark '%s' does not exist") % bmark) active = repo._activebookmark if bmark == active: prefix, label = '*', activebookmarklabel else: prefix, label = ' ', '' - bmarks[bmark] = (n, prefix, label) + bmarks[bmark] = (marks[bmark], prefix, label) _printbookmarks(ui, repo, fm, bmarks) def preparehookargs(name, old, new):