##// END OF EJS Templates
fix a bug where hg could remove file ending with .tmp...
Benoit Boissinot -
r1479:1a3c6689 default
parent child Browse files
Show More
@@ -377,8 +377,17 b' def opener(base):'
377 os.makedirs(d)
377 os.makedirs(d)
378 else:
378 else:
379 if nlink > 1:
379 if nlink > 1:
380 file(f + ".tmp", "wb").write(file(f, "rb").read())
380 d, fn = os.path.split(f)
381 rename(f+".tmp", f)
381 fd, temp = tempfile.mkstemp(prefix=fn, dir=d)
382 fp = os.fdopen(fd, "wb")
383 try:
384 fp.write(file(f, "rb").read())
385 except:
386 try: os.unlink(temp)
387 except: pass
388 raise
389 fp.close()
390 rename(temp, f)
382
391
383 return file(f, mode)
392 return file(f, mode)
384
393
General Comments 0
You need to be logged in to leave comments. Login now