[PATCH 1 of 2 V2] revset: make desc() function accept multiple arguments

Alexander Plavin alexander at plav.in
Thu Aug 22 13:42:02 CDT 2013


# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1377196193 -14400
#      Thu Aug 22 22:29:53 2013 +0400
# Node ID 52606445710a602c9ea290835f98eb436e78cccd
# Parent  e750d4c05d45410bfd51848374e9b2c479a8235a
revset: make desc() function accept multiple arguments

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

diff -r e750d4c05d45 -r 52606445710a 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)``
+    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 e750d4c05d45 -r 52606445710a 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)'


More information about the Mercurial-devel mailing list