comparison 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
comparison
equal deleted inserted replaced
41996:77ef3498ceb3 41997:4df7c4b70e03
1493 1493
1494 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a 1494 $ hg log -T "{indent(date, ' ')}\n" -r 2:3 -R a
1495 1200000.00 1495 1200000.00
1496 1300000.00 1496 1300000.00
1497 1497
1498 Test cbor filter:
1499
1500 $ cat <<'EOF' > "$TESTTMP/decodecbor.py"
1501 > from __future__ import absolute_import
1502 > from mercurial import pycompat
1503 > from mercurial.utils import (
1504 > cborutil,
1505 > stringutil,
1506 > )
1507 > items = cborutil.decodeall(pycompat.stdin.read())
1508 > pycompat.stdout.write(stringutil.pprint(items, indent=1) + b'\n')
1509 > EOF
1510
1511 $ hg log -T "{rev|cbor}" -R a -l2 | "$PYTHON" "$TESTTMP/decodecbor.py"
1512 [
1513 10,
1514 9
1515 ]
1516
1517 $ hg log -T "{extras|cbor}" -R a -l1 | "$PYTHON" "$TESTTMP/decodecbor.py"
1518 [
1519 {
1520 'branch': 'default'
1521 }
1522 ]
1523
1498 json filter should escape HTML tags so that the output can be embedded in hgweb: 1524 json filter should escape HTML tags so that the output can be embedded in hgweb:
1499 1525
1500 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1 1526 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
1501 "\u003cfoo@example.org\u003e" 1527 "\u003cfoo@example.org\u003e"
1502 1528