[PATCH 2 of 8] determine default locale encoding and stdio encoding on start-up

Andrey grooz-work at gorodok.net
Mon Nov 20 10:29:52 UTC 2006


# HG changeset patch
# User Andrey <grooz-work at gorodok.net>
# Date 1163345012 -21600
# Node ID cba3d15b1f26aafaa0a4b4d3e90c0529f18ebfd9
# Parent  c1622a4837a2483233b0d19b2ad2ea64b919f53e
determine default locale encoding and stdio encoding on start-up

diff -r c1622a4837a2 -r cba3d15b1f26 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())
@@ -49,6 +49,15 @@ class ui(object):
             self.readconfig(util.rcpath())
             self.check_trusted = True
             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