Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/debugcommands.py @ 38199:cc9aa88792fe
py3: wrap tempfile.NamedTemporaryFile() to return bytes fp.name
Unlike its name, tempfile.NamedTemporaryFile is not a class, so I renamed
the pycompat version to look like a plain function.
Since temp.name uses in the infinitepush extension aren't bytes-safe, this
patch leaves them unmodified. Another weird thing is tempfile.mktemp(),
which does not accept bytes suffix nor prefix. Sigh.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 26 May 2018 12:38:07 +0900 |
parents | aac4be30e250 |
children | ead71b15efd5 |
comparison
equal
deleted
inserted
replaced
38198:2ce60954b1b7 | 38199:cc9aa88792fe |
---|---|
19 import ssl | 19 import ssl |
20 import stat | 20 import stat |
21 import string | 21 import string |
22 import subprocess | 22 import subprocess |
23 import sys | 23 import sys |
24 import tempfile | |
25 import time | 24 import time |
26 | 25 |
27 from .i18n import _ | 26 from .i18n import _ |
28 from .node import ( | 27 from .node import ( |
29 bin, | 28 bin, |
968 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) | 967 ui.write(('fstype: %s\n') % (util.getfstype(path) or '(unknown)')) |
969 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) | 968 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no')) |
970 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) | 969 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
971 casesensitive = '(unknown)' | 970 casesensitive = '(unknown)' |
972 try: | 971 try: |
973 with tempfile.NamedTemporaryFile(prefix='.debugfsinfo', dir=path) as f: | 972 with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: |
974 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' | 973 casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
975 except OSError: | 974 except OSError: |
976 pass | 975 pass |
977 ui.write(('case-sensitive: %s\n') % casesensitive) | 976 ui.write(('case-sensitive: %s\n') % casesensitive) |
978 | 977 |