comparison tests/test-command-template.t @ 28212:d4419c01532b

templatefilters: make json filter be byte-transparent (BC) (issue4926) This is necessary to preserve filename encoding over JSON. Instead, this patch inserts "|utf8" where non-ascii local-encoding texts can be passed to "|json". See also the commit that introduced "utf8" filter.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 27 Dec 2015 17:59:57 +0900
parents 8ddf893560fa
children 7279e0132347
comparison
equal deleted inserted replaced
28211:446465888119 28212:d4419c01532b
3540 [255] 3540 [255]
3541 $ hg log -T "\\xy" -R a 3541 $ hg log -T "\\xy" -R a
3542 hg: parse error: invalid \x escape 3542 hg: parse error: invalid \x escape
3543 [255] 3543 [255]
3544 3544
3545 json filter should escape HTML tags so that the output can be embedded in hgweb:
3546
3547 $ hg log -T "{'<foo@example.org>'|json}\n" -R a -l1
3548 "\u003cfoo@example.org\u003e"
3549
3545 Set up repository for non-ascii encoding tests: 3550 Set up repository for non-ascii encoding tests:
3546 3551
3547 $ hg init nonascii 3552 $ hg init nonascii
3548 $ cd nonascii 3553 $ cd nonascii
3549 $ python <<EOF 3554 $ python <<EOF
3556 json filter should try round-trip conversion to utf-8: 3561 json filter should try round-trip conversion to utf-8:
3557 3562
3558 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0 3563 $ HGENCODING=ascii hg log -T "{branch|json}\n" -r0
3559 "\u00e9" 3564 "\u00e9"
3560 3565
3561 json filter should not abort if it can't decode bytes: 3566 json filter takes input as utf-8b:
3562 (not sure the current behavior is right; we might want to use utf-8b encoding?)
3563 3567
3564 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1 3568 $ HGENCODING=ascii hg log -T "{'`cat utf-8`'|json}\n" -l1
3565 "\ufffd\ufffd" 3569 "\u00e9"
3570 $ HGENCODING=ascii hg log -T "{'`cat latin1`'|json}\n" -l1
3571 "\udce9"
3566 3572
3567 utf8 filter: 3573 utf8 filter:
3568 3574
3569 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0 3575 $ HGENCODING=ascii hg log -T "round-trip: {branch|utf8|hex}\n" -r0
3570 round-trip: c3a9 3576 round-trip: c3a9