[PATCH] encoding: prefer the detected console encoding by default (issue2926)

Andrei Polushin polushin at gmail.com
Wed Jul 27 13:45:39 CDT 2011


# HG changeset patch
# User Andrei Polushin <polushin at gmail.com>
# Date 1311791944 -25200
# Branch stable
# Node ID 4ab82a7f26c42debb9ab361f3d822dd4ebc96dd7
# Parent  56848e2bb0c5a43b580dd2ca7ce1e781d4e75b2b
encoding: prefer the detected console encoding by default (issue2926)

The default installation of Mercurial should use the Windows OEM encoding
when running within the console window, which uses OEM encoding by default.

diff -r 56848e2bb0c5 -r 4ab82a7f26c4 mercurial/encoding.py
--- a/mercurial/encoding.py	Fri Jul 22 20:31:15 2011 -0300
+++ b/mercurial/encoding.py	Thu Jul 28 01:39:04 2011 +0700
@@ -6,6 +6,7 @@
 # GNU General Public License version 2 or any later version.
 
 import error
+import sys
 import unicodedata, locale, os
 
 def _getpreferredencoding():
@@ -41,6 +42,8 @@
 try:
     encoding = os.environ.get("HGENCODING")
     if not encoding:
+    	encoding = sys.stdout.encoding
+    if not encoding:
         encoding = locale.getpreferredencoding() or 'ascii'
         encoding = _encodingfixers.get(encoding, lambda: encoding)()
 except locale.Error:


More information about the Mercurial-devel mailing list