[PATCH] work around broken locale on darwin (MacOS X)

Christian Ebert blacktrash at gmx.net
Fri Jan 12 08:26:57 CST 2007


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1168611810 -3600
# Node ID f65f155be5c104d1a4a88660415c2305057fdfa7
# Parent  6ea8a3b805ee5ce9794ca653e85c40ac86ec468d
work around broken locale on darwin (MacOS X)

diff -r 6ea8a3b805ee -r f65f155be5c1 contrib/convert-repo
--- a/contrib/convert-repo	Wed Jan 10 20:35:27 2007 +0100
+++ b/contrib/convert-repo	Fri Jan 12 15:23:30 2007 +0100
@@ -23,7 +23,17 @@
 # on each commit copied, so convert-repo can be interrupted and can
 # be run repeatedly to copy new commits.
 
-import sys, os, zlib, sha, time, re, locale
+import sys, os, zlib, sha, time, re
+# work around broken locale on darwin
+if sys.platform != 'darwin':
+    import locale
+else:
+    try:
+        sys.platform = 'posix'
+        import locale
+    finally:
+        sys.platform = 'darwin'
+
 os.environ["HGENCODING"] = "utf-8"
 from mercurial import hg, ui, util, fancyopts
 
diff -r 6ea8a3b805ee -r f65f155be5c1 mercurial/util.py
--- a/mercurial/util.py	Wed Jan 10 20:35:27 2007 +0100
+++ b/mercurial/util.py	Fri Jan 12 15:23:30 2007 +0100
@@ -14,7 +14,16 @@ platform-specific details from the core.
 
 from i18n import _
 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
-import os, threading, time, calendar, ConfigParser, locale
+import os, threading, time, calendar, ConfigParser
+# work around broken locale on darwin
+if sys.platform != 'darwin':
+    import locale
+else:
+    try:
+        sys.platform = 'posix'
+        import locale
+    finally:
+        sys.platform = 'darwin'
 
 _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \
             or "ascii"


More information about the Mercurial-devel mailing list