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