[PATCH 5 of 6] revset: unify code flow in `bookmark`
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 18 16:40:58 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1410976705 25200
# Wed Sep 17 10:58:25 2014 -0700
# Node ID ac8639727377910aacfcd326bd3dec008a577b82
# Parent 542a93adfe2a1044d2f0b300c32e72670216001d
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.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -446,31 +446,29 @@ def bookmark(repo, subset, x):
if args:
bm = getstring(args[0],
# 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():
if matcher(name):
matchrevs.add(bmrev)
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):
"""``branch(string or set)``
All changesets belonging to the given branch or the branches of the given
More information about the Mercurial-devel
mailing list