revset: add desc(string) to search in commit messages
Like keyword(), but does not search in filenames and users.
No grepdesc() or descgrep() added, because it might be bad to introduce
grepfoo() versions of too many string searches.
--- a/mercurial/revset.py Thu Jun 16 22:03:26 2011 +0200
+++ b/mercurial/revset.py Thu Jun 16 22:47:34 2011 +0200
@@ -361,6 +361,19 @@
dm = util.matchdate(ds)
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.
+ """
+ # i18n: "desc" is a keyword
+ ds = getstring(x, _("desc requires a string")).lower()
+ l = []
+ for r in subset:
+ c = repo[r]
+ if ds in c.description().lower():
+ l.append(r)
+ return l
+
def descendants(repo, subset, x):
"""``descendants(set)``
Changesets which are descendants of changesets in set.
@@ -821,6 +834,7 @@
"closed": closed,
"contains": contains,
"date": date,
+ "desc": desc,
"descendants": descendants,
"file": hasfile,
"filelog": filelog,
@@ -920,7 +934,8 @@
elif op == 'func':
f = getstring(x[1], _("not a symbol"))
wa, ta = optimize(x[2], small)
- if f in "grep date user author keyword branch file outgoing closed":
+ if f in ("author branch closed date desc file grep keyword "
+ "outgoing user"):
w = 10 # slow
elif f in "modifies adds removes":
w = 30 # slower
--- a/tests/test-revset.t Thu Jun 16 22:03:26 2011 +0200
+++ b/tests/test-revset.t Thu Jun 16 22:47:34 2011 +0200
@@ -190,6 +190,8 @@
1
3
5
+ $ log 'desc(B)'
+ 5
$ log 'descendants(2 or 3)'
2
3