--- 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"