util: checknlink should remove file it creates if an exception occurs
authorTony Tung <tonytung@merly.org>
Fri, 19 Aug 2016 13:30:40 -0700
changeset 29832 bac1829ec31f
parent 29831 1316c7cccc76
child 29833 a8933d992a71
util: checknlink should remove file it creates if an exception occurs There's no reason to leave the file behind.
mercurial/util.py
--- a/mercurial/util.py	Tue Aug 23 17:58:53 2016 -0700
+++ b/mercurial/util.py	Fri Aug 19 13:30:40 2016 -0700
@@ -1341,6 +1341,10 @@
     try:
         posixfile(f1, 'w').close()
     except IOError:
+        try:
+            os.unlink(f1)
+        except OSError:
+            pass
         return False
 
     f2 = testfile + ".hgtmp2"