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

Andrey grooz-work at gorodok.net
Sun Nov 12 17:49:25 UTC 2006


# HG changeset patch
# User Andrey <grooz-work at gorodok.net>
# Date 1163345012 -21600
# Node ID 97bdd52eb920740375a449a3bb55078d10f9a163
# Parent  69bafd28ba10981bfc4cb2648a48aad2545fbe70
Determine default locale encoding and stdio encoding on start-up

diff -r 69bafd28ba10 -r 97bdd52eb920 mercurial/ui.py
--- a/mercurial/ui.py	Sun Nov 12 00:29:30 2006 +0600
+++ b/mercurial/ui.py	Sun Nov 12 21:23:32 2006 +0600
@@ -8,7 +8,7 @@ from i18n import gettext as _
 from i18n import gettext as _
 from demandload import *
 demandload(globals(), "errno getpass os re socket sys tempfile")
-demandload(globals(), "ConfigParser traceback util")
+demandload(globals(), "ConfigParser traceback util locale")
 
 def dupconfig(orig):
     new = util.configparser(orig.defaults())
@@ -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'])
         else:
             # parentui may point to an ui object which is already a child
             self.parentui = parentui.parentui or parentui



More information about the Mercurial-devel mailing list