comparison tests/test-command-template.t @ 20662:a54c0d830499 stable

templater: apply "stringify()" on sub expression to get string correctly Templating syntax allows nested expression to be specified as parts below, but they are evaluated as a generator and don't work correctly. - 'sep' of 'join(list, sep)' - 'text' and 'chars' of 'strip(text, chars)' In the former case, 'sep' returns expected string only for the first separation, and empty one for the second or later, because the generator has only one element. In the latter case, templating is aborted by exception, because the generator doesn't have 'strip()' method (as 'text') and can't be passed as the argument to 'str.strip()' (as 'chars'). This patch applies "stringify()" on these sub expression to get string correctly.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 10 Mar 2014 01:01:43 +0900
parents 7e627fe63e5e
children 5ab28a2e9962
comparison
equal deleted inserted replaced
20661:7e627fe63e5e 20662:a54c0d830499
1657 1657
1658 Test branches inside if statement: 1658 Test branches inside if statement:
1659 1659
1660 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n' 1660 $ hg log -r 0 --template '{if(branches, "yes", "no")}\n'
1661 no 1661 no
1662
1663 $ cd ..
1664
1665 Test stringify on sub expressions
1666
1667 $ hg log -R a -r 8 --template '{join(files, if("1", if("1", ", ")))}\n'
1668 fourth, second, third
1669 $ hg log -R a -r 8 --template '{strip(if("1", if("1", "-abc-")), if("1", if("1", "-")))}\n'
1670 abc