[PATCH 2 of 2 V2] revset: make keyword() function accept multiple arguments
Alexander Plavin
alexander at plav.in
Thu Aug 22 18:42:03 UTC 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1377196207 -14400
# Thu Aug 22 22:30:07 2013 +0400
# Node ID a213c1004a004877761ad6dd967722cfb1dac7d1
# Parent 52606445710a602c9ea290835f98eb436e78cccd
revset: make keyword() function accept multiple arguments
This provides a more convenient way to express a conjunction of
multiple keyword() calls with single argument.
diff -r 52606445710a -r a213c1004a00 mercurial/revset.py
--- a/mercurial/revset.py Thu Aug 22 22:29:53 2013 +0400
+++ b/mercurial/revset.py Thu Aug 22 22:30:07 2013 +0400
@@ -906,17 +906,22 @@
return [r for r in subset if r in hiddenrevs]
def keyword(repo, subset, x):
- """``keyword(string)``
- Search commit message, user name, and names of changed files for
- string. The match is case-insensitive.
+ """``keyword(*string)``
+ Search commit message, user name, and names of changed files for one or multiple strings.
+ The match is case-insensitive.
"""
# i18n: "keyword" is a keyword
- kw = encoding.lower(getstring(x, _("keyword requires a string")))
+ kws = getargs(x, 1, -1, _("keyword requires at least one argument"))
+ # i18n: "keyword" is a keyword
+ kws = [encoding.lower(getstring(kw, _("keyword requires string arguments")))
+ for kw in kws]
l = []
for r in subset:
c = repo[r]
- if util.any(kw in encoding.lower(t)
- for t in c.files() + [c.user(), c.description()]):
+ if util.all(
+ (util.any(kw in encoding.lower(t)
+ for t in c.files() + [c.user(), c.description()]))
+ for kw in kws):
l.append(r)
return l
diff -r 52606445710a -r a213c1004a00 tests/test-revset.t
--- a/tests/test-revset.t Thu Aug 22 22:29:53 2013 +0400
+++ b/tests/test-revset.t Thu Aug 22 22:30:07 2013 +0400
@@ -331,6 +331,10 @@
$ log 'keyword("test a")'
$ log 'desc(0, 1)'
9
+ $ log 'keyword(test, a)'
+ 0
+ 6
+ 9
$ log 'limit(head(), 1)'
0
$ log 'matching(6)'
More information about the Mercurial-devel
mailing list