Mercurial > hg
comparison tests/test-obsmarker-template.t @ 38707:6b5ca1d0aa1e
obsolete: store user name and note in UTF-8 (issue5754) (BC)
Before, user names were stored in local encoding and transferred across
repositories, which made it impossible to restore non-ASCII user names on
different platforms. This patch fixes new markers to be encoded in UTF-8
and decoded back to local encoding when displaying. Existing markers are
unfixable so they may result in mojibake.
I don't like the API that requires metadata dict to be UTF-8 encoded, which
is a source of bugs, but there's no abstraction layer to process the encoding
thingy efficiently. So we apply the same rule as extras dict to obsstore
metadata.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 15 Jul 2018 18:24:57 +0900 |
parents | ea63a2004d09 |
children | 2b7ce7b55514 |
comparison
equal
deleted
inserted
replaced
38706:83d965803325 | 38707:6b5ca1d0aa1e |
---|---|
2579 o changeset: 0:ea207398892e | 2579 o changeset: 0:ea207398892e |
2580 user: test | 2580 user: test |
2581 date: Thu Jan 01 00:00:00 1970 +0000 | 2581 date: Thu Jan 01 00:00:00 1970 +0000 |
2582 summary: ROOT | 2582 summary: ROOT |
2583 | 2583 |
2584 | |
2585 Test metadata encoding (issue5754) | |
2586 ================================== | |
2587 | |
2588 $ hg init $TESTTMP/metadata-encoding | |
2589 $ cd $TESTTMP/metadata-encoding | |
2590 $ cat <<'EOF' >> .hg/hgrc | |
2591 > [extensions] | |
2592 > amend = | |
2593 > EOF | |
2594 $ $PYTHON <<'EOF' | |
2595 > with open('test1', 'wb') as f: | |
2596 > f.write(b't\xe8st1') and None | |
2597 > with open('test2', 'wb') as f: | |
2598 > f.write(b't\xe8st2') and None | |
2599 > EOF | |
2600 $ mkcommit ROOT | |
2601 $ HGENCODING=latin-1 HGUSER="`cat test1`" mkcommit A0 | |
2602 $ echo 42 >> A0 | |
2603 $ hg amend -m "A1" --note "`cat test2`" | |
2604 $ HGENCODING=latin-1 hg amend -m "A2" \ | |
2605 > --config devel.user.obsmarker="`cat test2`" | |
2606 $ mkcommit B0 | |
2607 $ HGENCODING=latin-1 hg debugobsolete -u "`cat test2`" "`getid 'desc(B0)'`" | |
2608 obsoleted 1 changesets | |
2609 | |
2610 metadata should be stored in UTF-8, and debugobsolete doesn't decode it to | |
2611 local encoding since the command is supposed to show unmodified content: | |
2612 | |
2613 $ HGENCODING=latin-1 hg debugobsolete | |
2614 5f66a482f0bb2fcaccfc215554ad5eb9f40b50f5 718c0d00cee1429bdb73064e0d88908c601507a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'note': 't\xc3\xa8st2', 'operation': 'amend', 'user': 't\xc3\xa8st1'} | |
2615 718c0d00cee1429bdb73064e0d88908c601507a8 1132562159b35bb27e1d6b80c80ee94a1659a4da 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 't\xc3\xa8st2'} | |
2616 e1724525bc3bec4472d7915a02811b938004a7a2 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 't\xc3\xa8st2'} | |
2617 | |
2618 metadata should be converted back to local encoding when displaying: | |
2619 | |
2620 $ HGENCODING=latin-1 hg fatelog --hidden | |
2621 @ e1724525bc3b | |
2622 | Obsfate: pruned by t\xe8st2 (at 1970-01-01 00:00 +0000); (esc) | |
2623 o 1132562159b3 | |
2624 | | |
2625 | x 718c0d00cee1 | |
2626 |/ Obsfate: rewritten using amend as 3:1132562159b3 by t\xe8st2 (at 1970-01-01 00:00 +0000); (esc) | |
2627 | x 5f66a482f0bb | |
2628 |/ Obsfate: rewritten using amend as 2:718c0d00cee1 by t\xe8st1 (at 1970-01-01 00:00 +0000); (esc) | |
2629 o ea207398892e | |
2630 | |
2631 $ HGENCODING=utf-8 hg fatelog --hidden | |
2632 @ e1724525bc3b | |
2633 | Obsfate: pruned by t\xc3\xa8st2 (at 1970-01-01 00:00 +0000); (esc) | |
2634 o 1132562159b3 | |
2635 | | |
2636 | x 718c0d00cee1 | |
2637 |/ Obsfate: rewritten using amend as 3:1132562159b3 by t\xc3\xa8st2 (at 1970-01-01 00:00 +0000); (esc) | |
2638 | x 5f66a482f0bb | |
2639 |/ Obsfate: rewritten using amend as 2:718c0d00cee1 by t\xc3\xa8st1 (at 1970-01-01 00:00 +0000); (esc) | |
2640 o ea207398892e | |
2641 |