Mercurial > hg
changeset 14650:93731b3efd0d
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.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Thu, 16 Jun 2011 22:47:34 +0200 |
parents | a6a8809c6e33 |
children | e9e4e9ab62bd |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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