comparison tests/test-command-template.t @ 24280:6c55e37ba5f2

templater: allow piping generator-type function output to filters Template functions use "yield"s assuming that the result will be combined into a string, which means both "f -> str" and "f -> generator" should behave in the same way. Before this patch, piping generator function resulted in a cryptic error. We had to insert "|stringify" in this case. $ hg log --template '{if(author, author)|user}\n' abort: template filter 'userfilter' is not compatible with keyword '[(<function runsymbol at 0x7f5af2e8d8c0>, 'author'), (<function runsymbol at 0x7f5af2e8d8c0>, 'author')]'
author Yuya Nishihara <yuya@tcha.org>
date Tue, 24 Feb 2015 00:04:55 +0900
parents e7baf88c29c3
children 6ff513495a8b
comparison
equal deleted inserted replaced
24279:7cf9a9e0cf89 24280:6c55e37ba5f2
1899 1899
1900 $ hg tip --template '{foo()}\n' 1900 $ hg tip --template '{foo()}\n'
1901 hg: parse error: unknown function 'foo' 1901 hg: parse error: unknown function 'foo'
1902 [255] 1902 [255]
1903 1903
1904 Pass generator object created by template function to filter
1905
1906 $ hg log -l 1 --template '{if(author, author)|user}\n'
1907 test
1908
1904 Test diff function: 1909 Test diff function:
1905 1910
1906 $ hg diff -c 8 1911 $ hg diff -c 8
1907 diff -r 29114dbae42b -r 95c24699272e fourth 1912 diff -r 29114dbae42b -r 95c24699272e fourth
1908 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1913 --- /dev/null Thu Jan 01 00:00:00 1970 +0000