hgext/win32mbcs.py
changeset 9102 bbc78cb1bf15
parent 9077 22a33e207a7d
parent 9100 623f96ae3a26
child 9154 47ce7a3a1fb0
equal deleted inserted replaced
9092:9aebeea7ac00 9102:bbc78cb1bf15
    33 
    33 
    34 Path encoding conversion are done between Unicode and encoding.encoding which
    34 Path encoding conversion are done between Unicode and encoding.encoding which
    35 is decided by Mercurial from current locale setting or HGENCODING.
    35 is decided by Mercurial from current locale setting or HGENCODING.
    36 '''
    36 '''
    37 
    37 
    38 import os
    38 import os, sys
    39 from mercurial.i18n import _
    39 from mercurial.i18n import _
    40 from mercurial import util, encoding
    40 from mercurial import util, encoding
    41 
    41 
    42 def decode(arg):
    42 def decode(arg):
    43     if isinstance(arg, str):
    43     if isinstance(arg, str):
    74         # continue with calling original function.
    74         # continue with calling original function.
    75         raise util.Abort(_("[win32mbcs] filename conversion fail with"
    75         raise util.Abort(_("[win32mbcs] filename conversion fail with"
    76                          " %s encoding\n") % (encoding.encoding))
    76                          " %s encoding\n") % (encoding.encoding))
    77 
    77 
    78 def wrapname(name):
    78 def wrapname(name):
    79     idx = name.rfind('.')
    79     module, name = name.rsplit('.', 1)
    80     module = name[:idx]
    80     module = sys.modules[module]
    81     name = name[idx+1:]
       
    82     module = globals()[module]
       
    83     func = getattr(module, name)
    81     func = getattr(module, name)
    84     def f(*args):
    82     def f(*args):
    85         return wrapper(func, args)
    83         return wrapper(func, args)
    86     try:
    84     try:
    87         f.__name__ = func.__name__                # fail with python23
    85         f.__name__ = func.__name__                # fail with python23
    92 # List of functions to be wrapped.
    90 # List of functions to be wrapped.
    93 # NOTE: os.path.dirname() and os.path.basename() are safe because
    91 # NOTE: os.path.dirname() and os.path.basename() are safe because
    94 #       they use result of os.path.split()
    92 #       they use result of os.path.split()
    95 funcs = '''os.path.join os.path.split os.path.splitext
    93 funcs = '''os.path.join os.path.split os.path.splitext
    96  os.path.splitunc os.path.normpath os.path.normcase os.makedirs
    94  os.path.splitunc os.path.normpath os.path.normcase os.makedirs
    97  util.endswithsep util.splitpath util.checkcase util.fspath'''
    95  mercurial.util.endswithsep mercurial.util.splitpath mercurial.util.checkcase
       
    96  mercurial.util.fspath mercurial.windows.pconvert'''
    98 
    97 
    99 # codec and alias names of sjis and big5 to be faked.
    98 # codec and alias names of sjis and big5 to be faked.
   100 problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs
    99 problematic_encodings = '''big5 big5-tw csbig5 big5hkscs big5-hkscs
   101  hkscs cp932 932 ms932 mskanji ms-kanji shift_jis csshiftjis shiftjis
   100  hkscs cp932 932 ms932 mskanji ms-kanji shift_jis csshiftjis shiftjis
   102  sjis s_jis shift_jis_2004 shiftjis2004 sjis_2004 sjis2004
   101  sjis s_jis shift_jis_2004 shiftjis2004 sjis_2004 sjis2004