encoding of 'hg convert' output

Martin Geisler mg at lazybytes.net
Thu Aug 27 03:07:29 CDT 2009

FUJIWARA Katsunori <fujiwara at ascade.co.jp> writes:

> Hi all.
> 'convert' function overrides encoding configuration by UTF-8.
>     convert()@hgext/convert/convcmd.py
>     ====================
>     def convert(ui, src, dest=None, revmapfile=None, **opts):
>         global orig_encoding
>         orig_encoding = encoding.encoding
>         encoding.encoding = 'UTF-8'
>     ====================
> I interpret this as assurance of internal processing in UTF-8 while
> converting.

I guess so, but what a mess :-( I wonder how Mercurial would look if we
switched from bytestrings to Unicode strings internally.

> But this overriding forces encoding of 'hg convert' output to be UTF-8
> unexpectedly, when user specifies another encoding.
> So, I think that the result of gettext(), which is encoded by UTF-8,
> should be re-encoded by 'orig_encoding', at least for
> ui.warn()/status()/note()/debug()-ed and raise-d messages.

True, but wont it be quite annoying to call recode everywhere we output
something to the user?

Perhaps the convert function should stop playing with encoding.encoding.
The sources and sinks can then use their own encoding, which most of
them seems to do anyway (I saw lots of references to self.encoding).

Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.

More information about the Mercurial-devel mailing list