Mercurial > public > mercurial-scm > hg-stable
diff tests/test-template-functions.t @ 38454:bc8d925342f0
templater: extend filter() to accept template expression for emptiness test
This utilizes the pass-by-name nature of template arguments.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 14 Jun 2018 23:10:14 +0900 |
parents | dae829b4de78 |
children | a01200b25da6 |
line wrap: on
line diff
--- a/tests/test-template-functions.t Thu Jun 14 22:33:26 2018 +0900 +++ b/tests/test-template-functions.t Thu Jun 14 23:10:14 2018 +0900 @@ -449,6 +449,13 @@ $ hg log -R a -r 0 -T '{filter(revset("0:2"))}\n' 0 1 2 +Test filter() by expression: + + $ hg log -R a -r 1 -T '{filter(desc|splitlines, ifcontains("1", line, "t"))}\n' + other 1 + $ hg log -R a -r 0 -T '{filter(dict(a=0, b=1), ifeq(key, "b", "t"))}\n' + b=1 + Test filter() shouldn't crash: $ hg log -R a -r 0 -T '{filter(extras)}\n' @@ -459,7 +466,7 @@ Test filter() unsupported arguments: $ hg log -R a -r 0 -T '{filter()}\n' - hg: parse error: filter expects one argument + hg: parse error: filter expects one or two arguments [255] $ hg log -R a -r 0 -T '{filter(date)}\n' hg: parse error: date is not iterable @@ -476,6 +483,9 @@ $ hg log -R a -r 0 -T '{filter(succsandmarkers)}\n' hg: parse error: not filterable without template [255] + $ hg log -R a -r 0 -T '{filter(desc|splitlines % "{line}", "")}\n' + hg: parse error: not filterable by expression + [255] Test manifest/get() can be join()-ed as string, though it's silly: