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

Matt Mackall mpm at selenic.com
Mon Nov 13 18:00:14 UTC 2006


On Mon, Nov 13, 2006 at 12:53:44PM +0600, Andrey wrote:
> 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.

Just because Windows does it doesn't mean its useful. What are the
scenarios where Windows needs it?
 
> 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?

I'm not yet convinced locale support needs access to the config. If
the average internationalized app needed its own config tweaks,
everyone would just give up and use ASCII.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list