[PATCH 2 of 2 V3] revset: make keyword() function accept multiple arguments
Alexander Plavin
alexander at plav.in
Fri Sep 6 04:04:08 CDT 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1378017611 -14400
# Sun Sep 01 10:40:11 2013 +0400
# Node ID 4074e05bd30287df5d39d0b36a3bb42dbb8701ad
# Parent 9058d1306b28dcb57aaa7791924473a86661bef7
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 9058d1306b28 -r 4074e05bd302 mercurial/revset.py
--- a/mercurial/revset.py Thu Aug 22 22:29:53 2013 +0400
+++ b/mercurial/revset.py Sun Sep 01 10:40:11 2013 +0400
@@ -906,17 +906,22 @@
return [r for r in subset if r in hiddenrevs]
def keyword(repo, subset, x):
- """``keyword(string)``
+ """``keyword(string[, string...])``
Search commit message, user name, and names of changed files for
- string. The match is case-insensitive.
+ 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 9058d1306b28 -r 4074e05bd302 tests/test-revset.t
--- a/tests/test-revset.t Thu Aug 22 22:29:53 2013 +0400
+++ b/tests/test-revset.t Sun Sep 01 10:40:11 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