[PATCH 0 of 6] Improve readability of non-ascii hg emails (issue814)

Christian Ebert blacktrash at gmx.net
Wed Jul 9 16:33:41 UTC 2008


Hi,

I resubmit a patch series to improve handling of non-ascii mail.

Have been using it for quite some time now, w/o any probs; but I
understand that charset issues are a can of worms; so perhaps
someone is inspired to implement this more professionally.

I can testify that this is useful for projects that deal with
"normal" texts in utf and/or have users with non-ascii chars in
their names ;)

Patch 6 addresses issue #814.

The patch series has 2 main tasks:

1. Patches

Patches must be kept independent of conventions between sender
and recipient. They are sent in ascii, utf-8, or as fake ascii
(current behaviour; see also TODO). utf-8 is safe to detect.

2. Mail parts that do not contain patches

Introduce new [email] sendcharsets config (default:
util._encoding). us-ascii is always implied and tried first.

[email]
# for westerners
sendcharsets = iso-8859-1, iso-8859-15, windows-1252
# other examples:
# iso-8859-1, iso-8859-15, windows-1252, iso-8859-2, windows-1250
# iso-8859-1, iso-8859-15, windows-1252, iso-8859-2, windows-1250, iso-2022-jp, iso-2022-jp-ms

(idea stolen from Mutt)

For headers and message parts that do not contain patches the
convert function cycles through sendcharsets in descending order
to try a successful conversion.

Both $HGENCODING and util._fallbackencoding are tried for input.

As last resort the conversion falls back to fake ascii (ie. the
current behaviour).

All conversion is done in mailcharset.py module.

For "hg email --test" no conversion is done to leave output
readable.

TODO:
Force quoted-printable instead of base64?
Allow other utf charsets for patches?
How to handle patches containing 8-bit text and of course
changeset patches containing more than one charset. The cleanest
solution would probably be to send them as binary attachments
(application/x-patch? -- difficult w/o
email.MIME.MIMEApplication, introduced in Python 2.5).

The patch queue is also available at
<http://www.blacktrash.org/hg/hg-mail-mq/>

Crew repo with queue on top at
<http://www.blacktrash.org/hg/hg-mail-mq/>

c


More information about the Mercurial-devel mailing list