Mercurial > hg-stable
changeset 32039:2ab7578e685b
templatefilters: fix crash by string formatting of '{x|splitlines}'
Before, it crashed because mapping['templ'] was missing. As it didn't support
the legacy list template from the beginning, we can simply use hybridlist().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 15 Apr 2017 10:51:17 +0900 |
parents | 3920b5970f95 |
children | 0fb78cb90ca7 |
files | mercurial/templatefilters.py tests/test-command-template.t |
diffstat | 2 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Wed Apr 05 21:57:05 2017 +0900 +++ b/mercurial/templatefilters.py Sat Apr 15 10:51:17 2017 +0900 @@ -339,7 +339,7 @@ @templatefilter('splitlines') def splitlines(text): """Any text. Split text into a list of lines.""" - return templatekw.showlist('line', text.splitlines(), {}, plural='lines') + return templatekw.hybridlist(text.splitlines(), name='line') @templatefilter('stringescape') def stringescape(text):
--- a/tests/test-command-template.t Wed Apr 05 21:57:05 2017 +0900 +++ b/tests/test-command-template.t Sat Apr 15 10:51:17 2017 +0900 @@ -3894,6 +3894,11 @@ o foo line 1 foo line 2 + $ hg log -R a -r0 -T '{desc|splitlines}\n' + line 1 line 2 + $ hg log -R a -r0 -T '{join(desc|splitlines, "|")}\n' + line 1|line 2 + Test startswith $ hg log -Gv -R a --template "{startswith(desc)}" hg: parse error: startswith expects two arguments