About encoding manipulation in Mercurial

Matt Mackall mpm at selenic.com
Mon May 11 10:26:22 CDT 2009


On Mon, May 11, 2009 at 04:38:27PM +0800, LAO Zhongcheng wrote:
> Hi,
> I'm a newbie in Python.
> 
> Is the file mercurial/changelog.py the core API of Mercurial.
> I found there are some callings to fromlocal
> in the line listed below of changelog#add method.
> 208 user, desc = util.fromlocal(user), util.fromlocal(desc)
> 
> I suppose that if a Mercurial extension is going to call this method,
> it has to pass a username and description in default locale
> (system locale or HGENCODING environment).
> Am I right?

Correct. However, you should -not- try to coerce user or desc to local
encoding if for some reason they're not in local encoding. Instead,
you should temporarily change util._encoding.

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial mailing list