Mercurial > hg-stable
changeset 22499:8c9f9e346acc
revset: unify code flow in `bookmark`
We refactor the code of the bookmark revset to have a single return. This will
allow us to sanitize the content of the set.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 17 Sep 2014 10:58:25 -0700 |
parents | 64673dc48931 |
children | 171015d3b30c |
files | mercurial/revset.py |
diffstat | 1 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Wed Sep 17 10:59:30 2014 -0700 +++ b/mercurial/revset.py Wed Sep 17 10:58:25 2014 -0700 @@ -448,12 +448,12 @@ # i18n: "bookmark" is a keyword _('the argument to bookmark must be a string')) kind, pattern, matcher = _stringmatcher(bm) + bms = set() if kind == 'literal': bmrev = repo._bookmarks.get(pattern, None) if not bmrev: raise util.Abort(_("bookmark '%s' does not exist") % bm) - bmrev = repo[bmrev].rev() - return subset.filter(lambda r: r == bmrev) + bms.add(repo[bmrev].rev()) else: matchrevs = set() for name, bmrev in repo._bookmarks.iteritems(): @@ -462,13 +462,11 @@ if not matchrevs: raise util.Abort(_("no bookmarks exist that match '%s'") % pattern) - bmrevs = set() for bmrev in matchrevs: - bmrevs.add(repo[bmrev].rev()) - return subset & bmrevs - - bms = set([repo[r].rev() - for r in repo._bookmarks.values()]) + bms.add(repo[bmrev].rev()) + else: + bms = set([repo[r].rev() + for r in repo._bookmarks.values()]) return subset.filter(bms.__contains__) def branch(repo, subset, x):