Mercurial > hg
comparison tests/test-patchbomb.t @ 39037:ede768cfe83e
mail: always fall back to iso-8859-1 if us-ascii won't work (BC)
It looks like this was a well-intentioned backwards compat hack for
previewing the output of `hg email` in a stable way. Unfortunately I
think this hack's time has come, because Python 3 does a much better
job of ensuring it actually emits *valid* email messages. In
particular, Python 2 would blindly trust us that the bytes we handed
it were valid for the encoding we claimed, but Python 3 has some more
sniff-tests that we end up failing.
As a result, if we're going to print an email to the terminal, try
us-ascii first, but if that fails go straight to iso-8859-1 which
should be reasonably readable for ascii-compatible patch bodies. This
*will* be a breaking change for ascii-incompatible textual patch
content, but I don't think that's avoidable if we want to continue
using the email library from the stdlib.
.. bc::
Emails from the patchbomb extension will always be printed as though
they are iso-8859-1 if they're not valid us-ascii. Previously,
previewed emails were always claimed to be us-ascii and might
contain invalid byte sequences.
Differential Revision: https://phab.mercurial-scm.org/D4231
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 09 Aug 2018 21:04:15 -0400 |
parents | 598467614c15 |
children | f76c1343859d |
comparison
equal
deleted
inserted
replaced
39036:598467614c15 | 39037:ede768cfe83e |
---|---|
452 this patch series consists of 1 patches. | 452 this patch series consists of 1 patches. |
453 | 453 |
454 | 454 |
455 displaying [PATCH] utf-8 content ... | 455 displaying [PATCH] utf-8 content ... |
456 MIME-Version: 1.0 | 456 MIME-Version: 1.0 |
457 Content-Type: text/plain; charset="us-ascii" | 457 Content-Type: text/plain; charset="iso-8859-1" |
458 Content-Transfer-Encoding: 8bit | 458 Content-Transfer-Encoding: quoted-printable |
459 Subject: [PATCH] utf-8 content | 459 Subject: [PATCH] utf-8 content |
460 X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f | 460 X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f |
461 X-Mercurial-Series-Index: 1 | 461 X-Mercurial-Series-Index: 1 |
462 X-Mercurial-Series-Total: 1 | 462 X-Mercurial-Series-Total: 1 |
463 Message-Id: <909a00e13e9d78b575ae.240@*> (glob) | 463 Message-Id: <909a00e13e9d78b575ae.240@*> (glob) |
485 +description | 485 +description |
486 diff -r ff2c9fa2018b -r 909a00e13e9d utf | 486 diff -r ff2c9fa2018b -r 909a00e13e9d utf |
487 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 487 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
488 +++ b/utf Thu Jan 01 00:00:04 1970 +0000 | 488 +++ b/utf Thu Jan 01 00:00:04 1970 +0000 |
489 @@ -0,0 +1,1 @@ | 489 @@ -0,0 +1,1 @@ |
490 +h\xc3\xb6mma! (esc) | 490 +h=C3=B6mma! |
491 | 491 |
492 | 492 |
493 mime encoded mbox (base64): | 493 mime encoded mbox (base64): |
494 $ hg email --date '1970-1-1 0:4' -f 'Q <quux>' -t foo -c bar -r tip -m mbox | 494 $ hg email --date '1970-1-1 0:4' -f 'Q <quux>' -t foo -c bar -r tip -m mbox |
495 this patch series consists of 1 patches. | 495 this patch series consists of 1 patches. |
2671 @@ -0,0 +1,1 @@ | 2671 @@ -0,0 +1,1 @@ |
2672 +c | 2672 +c |
2673 | 2673 |
2674 displaying [PATCH 2 of 6] utf-8 content ... | 2674 displaying [PATCH 2 of 6] utf-8 content ... |
2675 MIME-Version: 1.0 | 2675 MIME-Version: 1.0 |
2676 Content-Type: text/plain; charset="us-ascii" | 2676 Content-Type: text/plain; charset="iso-8859-1" |
2677 Content-Transfer-Encoding: 8bit | 2677 Content-Transfer-Encoding: quoted-printable |
2678 Subject: [PATCH 2 of 6] utf-8 content | 2678 Subject: [PATCH 2 of 6] utf-8 content |
2679 X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f | 2679 X-Mercurial-Node: 909a00e13e9d78b575aeee23dddbada46d5a143f |
2680 X-Mercurial-Series-Index: 2 | 2680 X-Mercurial-Series-Index: 2 |
2681 X-Mercurial-Series-Total: 6 | 2681 X-Mercurial-Series-Total: 6 |
2682 Message-Id: <909a00e13e9d78b575ae.315532862@*> (glob) | 2682 Message-Id: <909a00e13e9d78b575ae.315532862@*> (glob) |
2705 +description | 2705 +description |
2706 diff -r ff2c9fa2018b -r 909a00e13e9d utf | 2706 diff -r ff2c9fa2018b -r 909a00e13e9d utf |
2707 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 2707 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
2708 +++ b/utf Thu Jan 01 00:00:04 1970 +0000 | 2708 +++ b/utf Thu Jan 01 00:00:04 1970 +0000 |
2709 @@ -0,0 +1,1 @@ | 2709 @@ -0,0 +1,1 @@ |
2710 +h\xc3\xb6mma! (esc) | 2710 +h=C3=B6mma! |
2711 | 2711 |
2712 displaying [PATCH 3 of 6] long line ... | 2712 displaying [PATCH 3 of 6] long line ... |
2713 MIME-Version: 1.0 | 2713 MIME-Version: 1.0 |
2714 Content-Type: text/plain; charset="us-ascii" | 2714 Content-Type: text/plain; charset="us-ascii" |
2715 Content-Transfer-Encoding: quoted-printable | 2715 Content-Transfer-Encoding: quoted-printable |
2756 + | 2756 + |
2757 +bar | 2757 +bar |
2758 | 2758 |
2759 displaying [PATCH 4 of 6] isolatin 8-bit encoding ... | 2759 displaying [PATCH 4 of 6] isolatin 8-bit encoding ... |
2760 MIME-Version: 1.0 | 2760 MIME-Version: 1.0 |
2761 Content-Type: text/plain; charset="us-ascii" | 2761 Content-Type: text/plain; charset="iso-8859-1" |
2762 Content-Transfer-Encoding: 8bit | 2762 Content-Transfer-Encoding: quoted-printable |
2763 Subject: [PATCH 4 of 6] isolatin 8-bit encoding | 2763 Subject: [PATCH 4 of 6] isolatin 8-bit encoding |
2764 X-Mercurial-Node: 240fb913fc1b7ff15ddb9f33e73d82bf5277c720 | 2764 X-Mercurial-Node: 240fb913fc1b7ff15ddb9f33e73d82bf5277c720 |
2765 X-Mercurial-Series-Index: 4 | 2765 X-Mercurial-Series-Index: 4 |
2766 X-Mercurial-Series-Total: 6 | 2766 X-Mercurial-Series-Total: 6 |
2767 Message-Id: <240fb913fc1b7ff15ddb.315532864@*> (glob) | 2767 Message-Id: <240fb913fc1b7ff15ddb.315532864@*> (glob) |
2783 | 2783 |
2784 diff -r a2ea8fc83dd8 -r 240fb913fc1b isolatin | 2784 diff -r a2ea8fc83dd8 -r 240fb913fc1b isolatin |
2785 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | 2785 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
2786 +++ b/isolatin Thu Jan 01 00:00:05 1970 +0000 | 2786 +++ b/isolatin Thu Jan 01 00:00:05 1970 +0000 |
2787 @@ -0,0 +1,1 @@ | 2787 @@ -0,0 +1,1 @@ |
2788 +h\xf6mma! (esc) | 2788 +h=F6mma! |
2789 | 2789 |
2790 displaying [PATCH 5 of 6] Added tag zero, zero.foo for changeset 8580ff50825a ... | 2790 displaying [PATCH 5 of 6] Added tag zero, zero.foo for changeset 8580ff50825a ... |
2791 MIME-Version: 1.0 | 2791 MIME-Version: 1.0 |
2792 Content-Type: text/plain; charset="us-ascii" | 2792 Content-Type: text/plain; charset="us-ascii" |
2793 Content-Transfer-Encoding: 7bit | 2793 Content-Transfer-Encoding: 7bit |