[PATCH 2 of 6] Determine default locale encoding and stdio encoding on start-up

Andrey grooz-work at gorodok.net
Mon Nov 13 06:53:44 UTC 2006


On 13 November 2006 (Mon) 06:10, Matt Mackall wrote:
> On Mon, Nov 13, 2006 at 12:49:25AM +0700, Andrey wrote:
> > @@ -48,6 +48,15 @@ class ui(object):
> >              self.ucdata = None
> >              self.readconfig(util.rcpath())
> >              self.updateopts(verbose, debug, quiet, interactive)
> > +
> > +            self.encodings = {}
> > +            self.encodings['default'] = (self.config("ui", "encoding")
> > +                                        or
> > locale.getpreferredencoding()) +            # windows may use different
> > encoding for stdio
> > +            self.encodings['stdio'] = (self.config("ui",
> > "stdio_encoding") +                                      or
> > self.config("ui", "encoding") +                                      or
> > sys.stdout.encoding or sys.stdin.encoding +                              
> >        or self.encodings['default'])
>
> Again, should be in util.py. Don't know if it makes sense to bother
> with two different config options. When is that useful?

I actually borrowed most of the code from 
http://www.selenic.com/mercurial/bts/issue156. :-) Having two different 
encodings is nessessary on Windows and maybe on other esotheric systems. 
And 'stdio_encoding' option could be useful if autodetection of encoding 
fails.

It would be nice indeed to move that code to util.py, but it needs access to 
config, and for some reason config loading is done in ui.py (I'd personally 
prefer having separate config.py module and read config file on first module 
import). Could someone comment on this?



More information about the Mercurial-devel mailing list