Show More
@@ -408,21 +408,21 if pycompat.iswindows: | |||||
408 | _INVALID_HANDLE_VALUE = -1 |
|
408 | _INVALID_HANDLE_VALUE = -1 | |
409 |
|
409 | |||
410 | class _COORD(ctypes.Structure): |
|
410 | class _COORD(ctypes.Structure): | |
411 | _fields_ = [('X', ctypes.c_short), |
|
411 | _fields_ = [(r'X', ctypes.c_short), | |
412 | ('Y', ctypes.c_short)] |
|
412 | (r'Y', ctypes.c_short)] | |
413 |
|
413 | |||
414 | class _SMALL_RECT(ctypes.Structure): |
|
414 | class _SMALL_RECT(ctypes.Structure): | |
415 | _fields_ = [('Left', ctypes.c_short), |
|
415 | _fields_ = [(r'Left', ctypes.c_short), | |
416 | ('Top', ctypes.c_short), |
|
416 | (r'Top', ctypes.c_short), | |
417 | ('Right', ctypes.c_short), |
|
417 | (r'Right', ctypes.c_short), | |
418 | ('Bottom', ctypes.c_short)] |
|
418 | (r'Bottom', ctypes.c_short)] | |
419 |
|
419 | |||
420 | class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): |
|
420 | class _CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): | |
421 | _fields_ = [('dwSize', _COORD), |
|
421 | _fields_ = [(r'dwSize', _COORD), | |
422 | ('dwCursorPosition', _COORD), |
|
422 | (r'dwCursorPosition', _COORD), | |
423 | ('wAttributes', _WORD), |
|
423 | (r'wAttributes', _WORD), | |
424 | ('srWindow', _SMALL_RECT), |
|
424 | (r'srWindow', _SMALL_RECT), | |
425 | ('dwMaximumWindowSize', _COORD)] |
|
425 | (r'dwMaximumWindowSize', _COORD)] | |
426 |
|
426 | |||
427 | _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11 |
|
427 | _STD_OUTPUT_HANDLE = 0xfffffff5 # (DWORD)-11 | |
428 | _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12 |
|
428 | _STD_ERROR_HANDLE = 0xfffffff4 # (DWORD)-12 | |
@@ -484,7 +484,7 if pycompat.iswindows: | |||||
484 | w32effects = None |
|
484 | w32effects = None | |
485 | else: |
|
485 | else: | |
486 | origattr = csbi.wAttributes |
|
486 | origattr = csbi.wAttributes | |
487 | ansire = re.compile('\033\[([^m]*)m([^\033]*)(.*)', |
|
487 | ansire = re.compile(b'\033\[([^m]*)m([^\033]*)(.*)', | |
488 | re.MULTILINE | re.DOTALL) |
|
488 | re.MULTILINE | re.DOTALL) | |
489 |
|
489 | |||
490 | def win32print(ui, writefunc, *msgs, **opts): |
|
490 | def win32print(ui, writefunc, *msgs, **opts): | |
@@ -516,15 +516,15 if pycompat.iswindows: | |||||
516 | # them if not found |
|
516 | # them if not found | |
517 | pass |
|
517 | pass | |
518 | # hack to ensure regexp finds data |
|
518 | # hack to ensure regexp finds data | |
519 | if not text.startswith('\033['): |
|
519 | if not text.startswith(b'\033['): | |
520 | text = '\033[m' + text |
|
520 | text = b'\033[m' + text | |
521 |
|
521 | |||
522 | # Look for ANSI-like codes embedded in text |
|
522 | # Look for ANSI-like codes embedded in text | |
523 | m = re.match(ansire, text) |
|
523 | m = re.match(ansire, text) | |
524 |
|
524 | |||
525 | try: |
|
525 | try: | |
526 | while m: |
|
526 | while m: | |
527 | for sattr in m.group(1).split(';'): |
|
527 | for sattr in m.group(1).split(b';'): | |
528 | if sattr: |
|
528 | if sattr: | |
529 | attr = mapcolor(int(sattr), attr) |
|
529 | attr = mapcolor(int(sattr), attr) | |
530 | ui.flush() |
|
530 | ui.flush() |
@@ -14,6 +14,7 import socket | |||||
14 | import stat as statmod |
|
14 | import stat as statmod | |
15 |
|
15 | |||
16 | from .. import ( |
|
16 | from .. import ( | |
|
17 | encoding, | |||
17 | pycompat, |
|
18 | pycompat, | |
18 | ) |
|
19 | ) | |
19 |
|
20 | |||
@@ -193,7 +194,8 else: | |||||
193 |
|
194 | |||
194 | def _raiseioerror(name): |
|
195 | def _raiseioerror(name): | |
195 | err = ctypes.WinError() |
|
196 | err = ctypes.WinError() | |
196 |
raise IOError(err.errno, '%s: %s' % (name, |
|
197 | raise IOError(err.errno, r'%s: %s' % (encoding.strfromlocal(name), | |
|
198 | err.strerror)) | |||
197 |
|
199 | |||
198 | class posixfile(object): |
|
200 | class posixfile(object): | |
199 | '''a file object aiming for POSIX-like semantics |
|
201 | '''a file object aiming for POSIX-like semantics | |
@@ -207,14 +209,14 else: | |||||
207 | remains but cannot be opened again or be recreated under the same name, |
|
209 | remains but cannot be opened again or be recreated under the same name, | |
208 | until all reading processes have closed the file.''' |
|
210 | until all reading processes have closed the file.''' | |
209 |
|
211 | |||
210 | def __init__(self, name, mode='r', bufsize=-1): |
|
212 | def __init__(self, name, mode=b'r', bufsize=-1): | |
211 | if 'b' in mode: |
|
213 | if b'b' in mode: | |
212 | flags = _O_BINARY |
|
214 | flags = _O_BINARY | |
213 | else: |
|
215 | else: | |
214 | flags = _O_TEXT |
|
216 | flags = _O_TEXT | |
215 |
|
217 | |||
216 | m0 = mode[0] |
|
218 | m0 = mode[0:1] | |
217 | if m0 == 'r' and '+' not in mode: |
|
219 | if m0 == b'r' and b'+' not in mode: | |
218 | flags |= _O_RDONLY |
|
220 | flags |= _O_RDONLY | |
219 | access = _GENERIC_READ |
|
221 | access = _GENERIC_READ | |
220 | else: |
|
222 | else: | |
@@ -223,15 +225,15 else: | |||||
223 | flags |= _O_RDWR |
|
225 | flags |= _O_RDWR | |
224 | access = _GENERIC_READ | _GENERIC_WRITE |
|
226 | access = _GENERIC_READ | _GENERIC_WRITE | |
225 |
|
227 | |||
226 | if m0 == 'r': |
|
228 | if m0 == b'r': | |
227 | creation = _OPEN_EXISTING |
|
229 | creation = _OPEN_EXISTING | |
228 | elif m0 == 'w': |
|
230 | elif m0 == b'w': | |
229 | creation = _CREATE_ALWAYS |
|
231 | creation = _CREATE_ALWAYS | |
230 | elif m0 == 'a': |
|
232 | elif m0 == b'a': | |
231 | creation = _OPEN_ALWAYS |
|
233 | creation = _OPEN_ALWAYS | |
232 | flags |= _O_APPEND |
|
234 | flags |= _O_APPEND | |
233 | else: |
|
235 | else: | |
234 | raise ValueError("invalid mode: %s" % mode) |
|
236 | raise ValueError(r"invalid mode: %s" % pycompat.sysstr(mode)) | |
235 |
|
237 | |||
236 | fh = _kernel32.CreateFileA(name, access, |
|
238 | fh = _kernel32.CreateFileA(name, access, | |
237 | _FILE_SHARE_READ | _FILE_SHARE_WRITE | _FILE_SHARE_DELETE, |
|
239 | _FILE_SHARE_READ | _FILE_SHARE_WRITE | _FILE_SHARE_DELETE, |
@@ -389,7 +389,7 def shellquote(s): | |||||
389 | """ |
|
389 | """ | |
390 | global _quotere |
|
390 | global _quotere | |
391 | if _quotere is None: |
|
391 | if _quotere is None: | |
392 | _quotere = re.compile(r'(\\*)("|\\$)') |
|
392 | _quotere = re.compile(br'(\\*)("|\\$)') | |
393 | global _needsshellquote |
|
393 | global _needsshellquote | |
394 | if _needsshellquote is None: |
|
394 | if _needsshellquote is None: | |
395 | # ":" is also treated as "safe character", because it is used as a part |
|
395 | # ":" is also treated as "safe character", because it is used as a part | |
@@ -397,11 +397,11 def shellquote(s): | |||||
397 | # safe because shlex.split() (kind of) treats it as an escape char and |
|
397 | # safe because shlex.split() (kind of) treats it as an escape char and | |
398 | # drops it. It will leave the next character, even if it is another |
|
398 | # drops it. It will leave the next character, even if it is another | |
399 | # "\". |
|
399 | # "\". | |
400 | _needsshellquote = re.compile(r'[^a-zA-Z0-9._:/-]').search |
|
400 | _needsshellquote = re.compile(br'[^a-zA-Z0-9._:/-]').search | |
401 | if s and not _needsshellquote(s) and not _quotere.search(s): |
|
401 | if s and not _needsshellquote(s) and not _quotere.search(s): | |
402 | # "s" shouldn't have to be quoted |
|
402 | # "s" shouldn't have to be quoted | |
403 | return s |
|
403 | return s | |
404 | return '"%s"' % _quotere.sub(r'\1\1\\\2', s) |
|
404 | return b'"%s"' % _quotere.sub(br'\1\1\\\2', s) | |
405 |
|
405 | |||
406 | def _unquote(s): |
|
406 | def _unquote(s): | |
407 | if s.startswith(b'"') and s.endswith(b'"'): |
|
407 | if s.startswith(b'"') and s.endswith(b'"'): |
General Comments 0
You need to be logged in to leave comments.
Login now