[PATCH 1 of 2] revset: add descs() function which searches for individual words
Alexander Plavin
alexander at plav.in
Mon Aug 5 16:20:55 CDT 2013
# HG changeset patch
# User Alexander Plavin <alexander at plav.in>
# Date 1375736748 -14400
# Tue Aug 06 01:05:48 2013 +0400
# Node ID bac960d92a8f2d6fd2f833ab041ffe386c76967d
# Parent ecb8e32e765eaf8e2df8d6535be6ca66275ca0df
revset: add descs() function which searches for individual words
This function provides a more convenient way to express a conjunction of
multiple desc() calls.
diff -r ecb8e32e765e -r bac960d92a8f mercurial/revset.py
--- a/mercurial/revset.py Tue Aug 06 00:52:06 2013 +0400
+++ b/mercurial/revset.py Tue Aug 06 01:05:48 2013 +0400
@@ -589,6 +589,22 @@
l.append(r)
return l
+def descs(repo, subset, x):
+ """``descs(string)``
+ Search commit message for all individual words from the string.
+ Equivalent to a conjunction of multiple desc() calls.
+ The match is case-insensitive.
+ """
+ # i18n: "descs" is a keyword
+ dses = encoding.lower(getstring(x, _("descs requires a string"))).split()
+ l = []
+ for r in subset:
+ c = repo[r]
+ if util.all(ds in encoding.lower(c.description())
+ for ds in dses):
+ l.append(r)
+ return l
+
def _descendants(repo, subset, x, followfirst=False):
args = getset(repo, list(repo), x)
if not args:
@@ -1551,6 +1567,7 @@
"converted": converted,
"date": date,
"desc": desc,
+ "descs": descs,
"descendants": descendants,
"_firstdescendants": _firstdescendants,
"destination": destination,
diff -r ecb8e32e765e -r bac960d92a8f tests/test-revset.t
--- a/tests/test-revset.t Tue Aug 06 00:52:06 2013 +0400
+++ b/tests/test-revset.t Tue Aug 06 01:05:48 2013 +0400
@@ -329,6 +329,8 @@
$ log 'keyword(issue)'
6
$ log 'keyword("test a")'
+ $ log 'descs("0 1")'
+ 9
$ log 'limit(head(), 1)'
0
$ log 'matching(6)'
More information about the Mercurial-devel
mailing list