Mercurial > public > mercurial-scm > hg-stable
diff tests/test-template-functions.t @ 41997:4df7c4b70e03
templatefilters: add {x|cbor} filter for custom CBOR output
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 10 Mar 2019 13:07:36 +0900 |
parents | 6704696141b8 |
children | a66965406528 |
line wrap: on
line diff
--- a/tests/test-template-functions.t Sun Mar 10 12:57:24 2019 +0900 +++ b/tests/test-template-functions.t Sun Mar 10 13:07:36 2019 +0900 @@ -1495,6 +1495,32 @@ 1200000.00 1300000.00 +Test cbor filter: + + $ cat <<'EOF' > "$TESTTMP/decodecbor.py" + > from __future__ import absolute_import + > from mercurial import pycompat + > from mercurial.utils import ( + > cborutil, + > stringutil, + > ) + > items = cborutil.decodeall(pycompat.stdin.read()) + > pycompat.stdout.write(stringutil.pprint(items, indent=1) + b'\n') + > EOF + + $ hg log -T "{rev|cbor}" -R a -l2 | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + 10, + 9 + ] + + $ hg log -T "{extras|cbor}" -R a -l1 | "$PYTHON" "$TESTTMP/decodecbor.py" + [ + { + 'branch': 'default' + } + ] + json filter should escape HTML tags so that the output can be embedded in hgweb: $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1