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