##// END OF EJS Templates
Use better names (hg-{usage}-{random}.{suffix}) for temporary files.
Thomas Arendsen Hein -
r2165:d821918e default
parent child Browse files
Show More
@@ -23,11 +23,11 b' class gpg:'
23 23 """ returns of the good and bad signatures"""
24 24 try:
25 25 # create temporary files
26 fd, sigfile = tempfile.mkstemp(prefix="hggpgsig")
26 fd, sigfile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".sig")
27 27 fp = os.fdopen(fd, 'wb')
28 28 fp.write(sig)
29 29 fp.close()
30 fd, datafile = tempfile.mkstemp(prefix="hggpgdata")
30 fd, datafile = tempfile.mkstemp(prefix="hg-gpg-", suffix=".txt")
31 31 fp = os.fdopen(fd, 'wb')
32 32 fp.write(data)
33 33 fp.close()
@@ -62,7 +62,7 b' try:'
62 62 except ImportError: pass
63 63
64 64 def diffstat(patch):
65 fd, name = tempfile.mkstemp()
65 fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt")
66 66 try:
67 67 p = popen2.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name)
68 68 try:
@@ -38,7 +38,7 b' class appendfile(object):'
38 38 self.tmpname = tmpname
39 39 self.tmpfp = open(self.tmpname, 'ab+')
40 40 else:
41 fd, self.tmpname = tempfile.mkstemp()
41 fd, self.tmpname = tempfile.mkstemp(prefix="hg-appendfile-")
42 42 self.tmpfp = os.fdopen(fd, 'ab+')
43 43 self.realfp = fp
44 44 self.offset = fp.tell()
@@ -303,7 +303,7 b' def write_bundle(cg, filename=None, comp'
303 303 raise util.Abort(_("file '%s' already exists"), filename)
304 304 fh = open(filename, "wb")
305 305 else:
306 fd, filename = tempfile.mkstemp(suffix=".hg", prefix="hg-bundle-")
306 fd, filename = tempfile.mkstemp(prefix="hg-bundle-", suffix=".hg")
307 307 fh = os.fdopen(fd, "wb")
308 308 cleanup = filename
309 309
@@ -1824,7 +1824,7 b' class localrepository(object):'
1824 1824
1825 1825 def temp(prefix, node):
1826 1826 pre = "%s~%s." % (os.path.basename(fn), prefix)
1827 (fd, name) = tempfile.mkstemp("", pre)
1827 (fd, name) = tempfile.mkstemp(prefix=pre)
1828 1828 f = os.fdopen(fd, "wb")
1829 1829 self.wwrite(fn, fl.read(node), f)
1830 1830 f.close()
@@ -46,11 +46,11 b' def tempfilter(s, cmd):'
46 46 the temporary files generated.'''
47 47 inname, outname = None, None
48 48 try:
49 infd, inname = tempfile.mkstemp(prefix='hgfin')
49 infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
50 50 fp = os.fdopen(infd, 'wb')
51 51 fp.write(s)
52 52 fp.close()
53 outfd, outname = tempfile.mkstemp(prefix='hgfout')
53 outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
54 54 os.close(outfd)
55 55 cmd = cmd.replace('INFILE', inname)
56 56 cmd = cmd.replace('OUTFILE', outname)
@@ -464,7 +464,7 b' def opener(base, audit=True):'
464 464
465 465 def mktempcopy(name):
466 466 d, fn = os.path.split(name)
467 fd, temp = tempfile.mkstemp(prefix=fn, dir=d)
467 fd, temp = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
468 468 fp = os.fdopen(fd, "wb")
469 469 try:
470 470 fp.write(file(name, "rb").read())
General Comments 0
You need to be logged in to leave comments. Login now