1000
1000
key_a = path_prefix_key(path_a)
1001
1001
key_b = path_prefix_key(path_b)
1002
1002
return cmp(key_a, key_b)
1005
_cached_user_encoding = None
1008
def get_user_encoding():
1009
"""Find out what the preferred user encoding is.
1011
This is generally the encoding that is used for command line parameters
1012
and file contents. This may be different from the terminal encoding
1013
or the filesystem encoding.
1015
:return: A string defining the preferred user encoding
1017
global _cached_user_encoding
1018
if _cached_user_encoding is not None:
1019
return _cached_user_encoding
1021
if sys.platform == 'darwin':
1022
# work around egregious python 2.4 bug
1023
sys.platform = 'posix'
1027
sys.platform = 'darwin'
1032
_cached_user_encoding = locale.getpreferredencoding()
1033
except locale.Error, e:
1034
sys.stderr.write('bzr: warning: %s\n'
1035
' Could not what text encoding to use.\n'
1036
' This error usually means your Python interpreter\n'
1037
' doesn\'t support the locale set by $LANG (%s)\n'
1038
" Continuing with ascii encoding.\n"
1039
% (e, os.environ.get('LANG')))
1041
if _cached_user_encoding is None:
1042
_cached_user_encoding = 'ascii'
1043
return _cached_user_encoding