##// END OF EJS Templates
win32mbcs: unbyteify some strings for py3 support...
Matt Harbison -
r51635:48d9af6b stable
parent child Browse files
Show More
@@ -82,7 +82,7 b' def decode(arg):'
82 uarg = arg.decode(_encoding)
82 uarg = arg.decode(_encoding)
83 if arg == uarg.encode(_encoding):
83 if arg == uarg.encode(_encoding):
84 return uarg
84 return uarg
85 raise UnicodeError(b"Not local encoding")
85 raise UnicodeError("Not local encoding")
86 elif isinstance(arg, tuple):
86 elif isinstance(arg, tuple):
87 return tuple(map(decode, arg))
87 return tuple(map(decode, arg))
88 elif isinstance(arg, list):
88 elif isinstance(arg, list):
@@ -111,8 +111,8 b' def appendsep(s):'
111 try:
111 try:
112 us = decode(s)
112 us = decode(s)
113 except UnicodeError:
113 except UnicodeError:
114 us = s
114 us = s # TODO: how to handle this bytes case??
115 if us and us[-1] not in b':/\\':
115 if us and us[-1] not in ':/\\':
116 s += pycompat.ossep
116 s += pycompat.ossep
117 return s
117 return s
118
118
@@ -148,13 +148,13 b' def wrapperforlistdir(func, args, kwds):'
148 if args:
148 if args:
149 args = list(args)
149 args = list(args)
150 args[0] = appendsep(args[0])
150 args[0] = appendsep(args[0])
151 if b'path' in kwds:
151 if 'path' in kwds:
152 kwds[b'path'] = appendsep(kwds[b'path'])
152 kwds['path'] = appendsep(kwds['path'])
153 return func(*args, **kwds)
153 return func(*args, **kwds)
154
154
155
155
156 def wrapname(name, wrapper):
156 def wrapname(name: str, wrapper):
157 module, name = name.rsplit(b'.', 1)
157 module, name = name.rsplit('.', 1)
158 module = sys.modules[module]
158 module = sys.modules[module]
159 func = getattr(module, name)
159 func = getattr(module, name)
160
160
@@ -168,7 +168,7 b' def wrapname(name, wrapper):'
168 # List of functions to be wrapped.
168 # List of functions to be wrapped.
169 # NOTE: os.path.dirname() and os.path.basename() are safe because
169 # NOTE: os.path.dirname() and os.path.basename() are safe because
170 # they use result of os.path.split()
170 # they use result of os.path.split()
171 funcs = b'''os.path.join os.path.split os.path.splitext
171 funcs = '''os.path.join os.path.split os.path.splitext
172 os.path.normpath os.makedirs mercurial.util.endswithsep
172 os.path.normpath os.makedirs mercurial.util.endswithsep
173 mercurial.util.splitpath mercurial.util.fscasesensitive
173 mercurial.util.splitpath mercurial.util.fscasesensitive
174 mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
174 mercurial.util.fspath mercurial.util.pconvert mercurial.util.normpath
@@ -178,11 +178,11 b" funcs = b'''os.path.join os.path.split o"
178 # These functions are required to be called with local encoded string
178 # These functions are required to be called with local encoded string
179 # because they expects argument is local encoded string and cause
179 # because they expects argument is local encoded string and cause
180 # problem with unicode string.
180 # problem with unicode string.
181 rfuncs = b'''mercurial.encoding.upper mercurial.encoding.lower
181 rfuncs = '''mercurial.encoding.upper mercurial.encoding.lower
182 mercurial.util._filenamebytestr'''
182 mercurial.util._filenamebytestr'''
183
183
184 # List of Windows specific functions to be wrapped.
184 # List of Windows specific functions to be wrapped.
185 winfuncs = b'''os.path.splitunc'''
185 winfuncs = '''os.path.splitunc'''
186
186
187 # codec and alias names of sjis and big5 to be faked.
187 # codec and alias names of sjis and big5 to be faked.
188 problematic_encodings = b'''big5 big5-tw csbig5 big5hkscs big5-hkscs
188 problematic_encodings = b'''big5 big5-tw csbig5 big5hkscs big5-hkscs
@@ -208,15 +208,15 b' def extsetup(ui):'
208 if pycompat.iswindows:
208 if pycompat.iswindows:
209 for f in winfuncs.split():
209 for f in winfuncs.split():
210 wrapname(f, wrapper)
210 wrapname(f, wrapper)
211 wrapname(b"mercurial.util.listdir", wrapperforlistdir)
211 wrapname("mercurial.util.listdir", wrapperforlistdir)
212 wrapname(b"mercurial.windows.listdir", wrapperforlistdir)
212 wrapname("mercurial.windows.listdir", wrapperforlistdir)
213 # wrap functions to be called with local byte string arguments
213 # wrap functions to be called with local byte string arguments
214 for f in rfuncs.split():
214 for f in rfuncs.split():
215 wrapname(f, reversewrapper)
215 wrapname(f, reversewrapper)
216 # Check sys.args manually instead of using ui.debug() because
216 # Check sys.args manually instead of using ui.debug() because
217 # command line options is not yet applied when
217 # command line options is not yet applied when
218 # extensions.loadall() is called.
218 # extensions.loadall() is called.
219 if b'--debug' in sys.argv:
219 if '--debug' in sys.argv:
220 ui.writenoi18n(
220 ui.writenoi18n(
221 b"[win32mbcs] activated with encoding: %s\n" % _encoding
221 b"[win32mbcs] activated with encoding: %s\n" % _encoding
222 )
222 )
General Comments 0
You need to be logged in to leave comments. Login now