mercurial/util.py
changeset 4540 133a52d70958
parent 4533 36abb07c79d4
child 4625 eaf87cd19337
equal deleted inserted replaced
4539:e6c69a2491ed 4540:133a52d70958
    15 from i18n import _
    15 from i18n import _
    16 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
    16 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile
    17 import os, threading, time, calendar, ConfigParser, locale, glob
    17 import os, threading, time, calendar, ConfigParser, locale, glob
    18 
    18 
    19 try:
    19 try:
    20     _encoding = os.environ.get("HGENCODING") or locale.getpreferredencoding() \
    20     _encoding = os.environ.get("HGENCODING")
    21                 or "ascii"
    21     if sys.platform == 'darwin' and not _encoding:
       
    22         # On darwin, getpreferredencoding ignores the locale environment and
       
    23         # always returns mac-roman. We override this if the environment is
       
    24         # not C (has been customized by the user).
       
    25         locale.setlocale(locale.LC_CTYPE, '')
       
    26         _encoding = locale.getlocale()[1]
       
    27     if not _encoding:
       
    28         _encoding = locale.getpreferredencoding() or 'ascii'
    22 except locale.Error:
    29 except locale.Error:
    23     _encoding = 'ascii'
    30     _encoding = 'ascii'
    24 _encodingmode = os.environ.get("HGENCODINGMODE", "strict")
    31 _encodingmode = os.environ.get("HGENCODINGMODE", "strict")
    25 _fallbackencoding = 'ISO-8859-1'
    32 _fallbackencoding = 'ISO-8859-1'
    26 
    33