Show More
@@ -120,6 +120,8 b' class externalbundlestore(abstractbundle' | |||
|
120 | 120 | def write(self, data): |
|
121 | 121 | # Won't work on windows because you can't open file second time without |
|
122 | 122 | # closing it |
|
123 | # TODO: rewrite without str.format() and replace NamedTemporaryFile() | |
|
124 | # with pycompat.namedtempfile() | |
|
123 | 125 | with NamedTemporaryFile() as temp: |
|
124 | 126 | temp.write(data) |
|
125 | 127 | temp.flush() |
@@ -142,6 +144,8 b' class externalbundlestore(abstractbundle' | |||
|
142 | 144 | def read(self, handle): |
|
143 | 145 | # Won't work on windows because you can't open file second time without |
|
144 | 146 | # closing it |
|
147 | # TODO: rewrite without str.format() and replace NamedTemporaryFile() | |
|
148 | # with pycompat.namedtempfile() | |
|
145 | 149 | with NamedTemporaryFile() as temp: |
|
146 | 150 | formatted_args = [arg.format(filename=temp.name, handle=handle) |
|
147 | 151 | for arg in self.get_args] |
@@ -21,7 +21,6 b' import stat' | |||
|
21 | 21 | import string |
|
22 | 22 | import subprocess |
|
23 | 23 | import sys |
|
24 | import tempfile | |
|
25 | 24 | import time |
|
26 | 25 | |
|
27 | 26 | from .i18n import _ |
@@ -970,7 +969,7 b' def debugfsinfo(ui, path="."):' | |||
|
970 | 969 | ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no')) |
|
971 | 970 | casesensitive = '(unknown)' |
|
972 | 971 | try: |
|
973 |
with |
|
|
972 | with pycompat.namedtempfile(prefix='.debugfsinfo', dir=path) as f: | |
|
974 | 973 | casesensitive = util.fscasesensitive(f.name) and 'yes' or 'no' |
|
975 | 974 | except OSError: |
|
976 | 975 | pass |
@@ -249,16 +249,15 b' def checklink(path):' | |||
|
249 | 249 | else: |
|
250 | 250 | checkdir = path |
|
251 | 251 | cachedir = None |
|
252 |
|
|
|
253 | name = tempfile.mktemp(dir=fscheckdir, | |
|
252 | name = tempfile.mktemp(dir=pycompat.fsdecode(checkdir), | |
|
254 | 253 | prefix=r'checklink-') |
|
255 | 254 | name = pycompat.fsencode(name) |
|
256 | 255 | try: |
|
257 | 256 | fd = None |
|
258 | 257 | if cachedir is None: |
|
259 |
fd = |
|
|
260 |
|
|
|
261 |
target = |
|
|
258 | fd = pycompat.namedtempfile(dir=checkdir, | |
|
259 | prefix='hg-checklink-') | |
|
260 | target = os.path.basename(fd.name) | |
|
262 | 261 | else: |
|
263 | 262 | # create a fixed file to link to; doesn't matter if it |
|
264 | 263 | # already exists. |
@@ -392,3 +392,11 b" def mkdtemp(suffix=b'', prefix=b'tmp', d" | |||
|
392 | 392 | # text=True is not supported; use util.from/tonativeeol() instead |
|
393 | 393 | def mkstemp(suffix=b'', prefix=b'tmp', dir=None): |
|
394 | 394 | return tempfile.mkstemp(suffix, prefix, dir) |
|
395 | ||
|
396 | # mode must include 'b'ytes as encoding= is not supported | |
|
397 | def namedtempfile(mode=b'w+b', bufsize=-1, suffix=b'', prefix=b'tmp', dir=None, | |
|
398 | delete=True): | |
|
399 | mode = sysstr(mode) | |
|
400 | assert r'b' in mode | |
|
401 | return tempfile.NamedTemporaryFile(mode, bufsize, suffix=suffix, | |
|
402 | prefix=prefix, dir=dir, delete=delete) |
General Comments 0
You need to be logged in to leave comments.
Login now