Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 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 | 4b93bd041772 |
comparison
equal
deleted
inserted
replaced
14649:a6a8809c6e33 | 14650:93731b3efd0d |
---|---|
359 # i18n: "date" is a keyword | 359 # i18n: "date" is a keyword |
360 ds = getstring(x, _("date requires a string")) | 360 ds = getstring(x, _("date requires a string")) |
361 dm = util.matchdate(ds) | 361 dm = util.matchdate(ds) |
362 return [r for r in subset if dm(repo[r].date()[0])] | 362 return [r for r in subset if dm(repo[r].date()[0])] |
363 | 363 |
364 def desc(repo, subset, x): | |
365 """``desc(string)`` | |
366 Search commit message for string. The match is case-insensitive. | |
367 """ | |
368 # i18n: "desc" is a keyword | |
369 ds = getstring(x, _("desc requires a string")).lower() | |
370 l = [] | |
371 for r in subset: | |
372 c = repo[r] | |
373 if ds in c.description().lower(): | |
374 l.append(r) | |
375 return l | |
376 | |
364 def descendants(repo, subset, x): | 377 def descendants(repo, subset, x): |
365 """``descendants(set)`` | 378 """``descendants(set)`` |
366 Changesets which are descendants of changesets in set. | 379 Changesets which are descendants of changesets in set. |
367 """ | 380 """ |
368 args = getset(repo, range(len(repo)), x) | 381 args = getset(repo, range(len(repo)), x) |
819 "branch": branch, | 832 "branch": branch, |
820 "children": children, | 833 "children": children, |
821 "closed": closed, | 834 "closed": closed, |
822 "contains": contains, | 835 "contains": contains, |
823 "date": date, | 836 "date": date, |
837 "desc": desc, | |
824 "descendants": descendants, | 838 "descendants": descendants, |
825 "file": hasfile, | 839 "file": hasfile, |
826 "filelog": filelog, | 840 "filelog": filelog, |
827 "follow": follow, | 841 "follow": follow, |
828 "grep": grep, | 842 "grep": grep, |
918 wb, tb = optimize(x[2], small) | 932 wb, tb = optimize(x[2], small) |
919 return wa + wb, (op, ta, tb) | 933 return wa + wb, (op, ta, tb) |
920 elif op == 'func': | 934 elif op == 'func': |
921 f = getstring(x[1], _("not a symbol")) | 935 f = getstring(x[1], _("not a symbol")) |
922 wa, ta = optimize(x[2], small) | 936 wa, ta = optimize(x[2], small) |
923 if f in "grep date user author keyword branch file outgoing closed": | 937 if f in ("author branch closed date desc file grep keyword " |
938 "outgoing user"): | |
924 w = 10 # slow | 939 w = 10 # slow |
925 elif f in "modifies adds removes": | 940 elif f in "modifies adds removes": |
926 w = 30 # slower | 941 w = 30 # slower |
927 elif f == "contains": | 942 elif f == "contains": |
928 w = 100 # very slow | 943 w = 100 # very slow |