[PATCH 2 of 2] convert: use encoding.encoding instead of locale.getpreferredencoding()

Brodie Rao brodie at bitheap.org
Wed Aug 18 09:53:58 CDT 2010


# HG changeset patch
# User Brodie Rao <brodie at bitheap.org>
# Date 1282143232 14400
# Branch stable
# Node ID 07484d1961be2b0f90f78135c2475c54b46cc785
# Parent  66b1cc9faafe73cc8690e523979d7c47d0d7fa6f
convert: use encoding.encoding instead of locale.getpreferredencoding()

The latter may not return useful results in certain OS X environments.

diff -r 66b1cc9faafe -r 07484d1961be hgext/convert/cvs.py
--- a/hgext/convert/cvs.py	Wed Aug 18 10:53:50 2010 -0400
+++ b/hgext/convert/cvs.py	Wed Aug 18 10:53:52 2010 -0400
@@ -5,9 +5,9 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import os, locale, re, socket, errno
+import os, re, socket, errno
 from cStringIO import StringIO
-from mercurial import util
+from mercurial import encoding, util
 from mercurial.i18n import _
 
 from common import NoRepo, commit, converter_source, checktool
@@ -30,7 +30,7 @@ class convert_cvs(converter_source):
         self.socket = None
         self.cvsroot = open(os.path.join(cvs, "Root")).read()[:-1]
         self.cvsrepo = open(os.path.join(cvs, "Repository")).read()[:-1]
-        self.encoding = locale.getpreferredencoding()
+        self.encoding = encoding.encoding
 
         self._connect()
 
diff -r 66b1cc9faafe -r 07484d1961be hgext/convert/gnuarch.py
--- a/hgext/convert/gnuarch.py	Wed Aug 18 10:53:50 2010 -0400
+++ b/hgext/convert/gnuarch.py	Wed Aug 18 10:53:52 2010 -0400
@@ -8,8 +8,8 @@
 
 from common import NoRepo, commandline, commit, converter_source
 from mercurial.i18n import _
-from mercurial import util
-import os, shutil, tempfile, stat, locale
+from mercurial import encoding, util
+import os, shutil, tempfile, stat
 from email.Parser import Parser
 
 class gnuarch_source(converter_source, commandline):
@@ -55,7 +55,7 @@ class gnuarch_source(converter_source, c
         self.parents = {}
         self.tags = {}
         self.catlogparser = Parser()
-        self.encoding = locale.getpreferredencoding()
+        self.encoding = encoding.encoding
         self.archives = []
 
     def before(self):


More information about the Mercurial-devel mailing list