comparison tests/test-command-template.t @ 34534:b3073e175c17

templater: wrap get/min/max result so map operation can apply to element See the test for usage example. wraphybridvalue() takes a key/value pair because a hybrid dict passes a key to its makemap() function. Since makemap() of showmanifest() doesn't need a key, it's set to None.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Sep 2017 19:13:25 +0900
parents 89aec1834a86
children 78590585c0db
comparison
equal deleted inserted replaced
34533:163fa0aea71e 34534:b3073e175c17
3126 $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n' 3126 $ hg log -R latesttag -r tip -T 'string length: {manifest|count}\n'
3127 string length: 15 3127 string length: 15
3128 $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n' 3128 $ hg log -R latesttag -r tip -T '{manifest % "{rev}:{node}"}\n'
3129 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc 3129 11:2bc6e9006ce29882383a22d39fd1f4e66dd3e2fc
3130 3130
3131 Test manifest can be join()-ed as before, though it's silly: 3131 $ hg log -R latesttag -r tip -T '{get(extras, "branch") % "{key}: {value}\n"}'
3132 branch: default
3133 $ hg log -R latesttag -r tip -T '{get(extras, "unknown") % "{key}\n"}'
3134 hg: parse error: None is not iterable
3135 [255]
3136 $ hg log -R latesttag -r tip -T '{min(extras) % "{key}: {value}\n"}'
3137 branch: default
3138 $ hg log -R latesttag -l1 -T '{min(revset("0:9")) % "{rev}:{node|short}\n"}'
3139 0:ce3cec86e6c2
3140 $ hg log -R latesttag -l1 -T '{max(revset("0:9")) % "{rev}:{node|short}\n"}'
3141 9:fbc7cd862e9c
3142
3143 Test manifest/get() can be join()-ed as before, though it's silly:
3132 3144
3133 $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n' 3145 $ hg log -R latesttag -r tip -T '{join(manifest, "")}\n'
3134 11:2bc6e9006ce2 3146 11:2bc6e9006ce2
3147 $ hg log -R latesttag -r tip -T '{join(get(extras, "branch"), "")}\n'
3148 default
3135 3149
3136 Test the sub function of templating for expansion: 3150 Test the sub function of templating for expansion:
3137 3151
3138 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n' 3152 $ hg log -R latesttag -r 10 --template '{sub("[0-9]", "x", "{rev}")}\n'
3139 xx 3153 xx