Managing multiple encodings in one repository

David Rushby davidrushby at gmail.com
Thu Apr 5 11:30:53 CDT 2007


A few minutes ago, I wrote:
> Mercurial is going right ahead and trying to read Mercurial.ini as if
> it were encoded in the system default encoding.  If I replace the line
> fp = open(f)
> in ui.py:ui:readconfig with
> import codecs; fp = codecs.open(f, encoding='utf16')
> then Mercurial is able to read a UTF-16-encoded Mercurial.ini.
> Obviously, a real fix would need to use the active Mercurial encoding
> instead of hard-coded 'utf16'.

That description of the problem is correct, but the suggested solution
would not be adequately flexible.  The "general" Mercurial encoding
and the encoding by which the config file is read really need to be
separately specifiable.  It doesn't make sense to have to convert
one's config file to a different encoding every time one wants to use
a different --encoding on the command line.

The only good solution that I can think of is to adopt a
first-line-encoding-directive solution for the config file, similar to
Python's "#-*- coding: xxx -*-".


More information about the Mercurial mailing list