Patchwork [1,of,2,V3] revset: make desc() function accept multiple arguments

login
register
mail settings
Submitter Alexander Plavin
Date Sept. 6, 2013, 9:04 a.m.
Message ID <9058d1306b28dcb57aaa.1378458247@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2390/
State Rejected
Headers show

Comments

Alexander Plavin - Sept. 6, 2013, 9:04 a.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1377196193 -14400
#      Thu Aug 22 22:29:53 2013 +0400
# Node ID 9058d1306b28dcb57aaa7791924473a86661bef7
# Parent  cf26d9c918f6f0943f39e8116ca807da1e4e8525
revset: make desc() function accept multiple arguments

This provides a more convenient way to express a conjunction of
multiple desc() calls with single argument.

Patch

diff -r cf26d9c918f6 -r 9058d1306b28 mercurial/revset.py
--- a/mercurial/revset.py	Tue Aug 06 00:52:06 2013 +0400
+++ b/mercurial/revset.py	Thu Aug 22 22:29:53 2013 +0400
@@ -577,15 +577,20 @@ 
     return [r for r in subset if dm(repo[r].date()[0])]
 
 def desc(repo, subset, x):
-    """``desc(string)``
-    Search commit message for string. The match is case-insensitive.
+    """``desc(string[, string...])``
+    Search commit message for one or multiple strings.
+    The match is case-insensitive.
     """
     # i18n: "desc" is a keyword
-    ds = encoding.lower(getstring(x, _("desc requires a string")))
+    dses = getargs(x, 1, -1, _("desc requires at least one argument"))
+    # i18n: "desc" is a keyword
+    dses = [encoding.lower(getstring(ds, _("desc requires string arguments")))
+            for ds in dses]
     l = []
     for r in subset:
         c = repo[r]
-        if ds in encoding.lower(c.description()):
+        if util.all(ds in encoding.lower(c.description())
+                    for ds in dses):
             l.append(r)
     return l
 
diff -r cf26d9c918f6 -r 9058d1306b28 tests/test-revset.t
--- a/tests/test-revset.t	Tue Aug 06 00:52:06 2013 +0400
+++ b/tests/test-revset.t	Thu Aug 22 22:29:53 2013 +0400
@@ -329,6 +329,8 @@ 
   $ log 'keyword(issue)'
   6
   $ log 'keyword("test a")'
+  $ log 'desc(0, 1)'
+  9
   $ log 'limit(head(), 1)'
   0
   $ log 'matching(6)'