mercurial/localrepo.py
changeset 31209 dd2364f5180a
parent 31148 3eaff87a0a89
child 31231 0a38a313033e
--- a/mercurial/localrepo.py	Wed Mar 01 18:21:06 2017 -0800
+++ b/mercurial/localrepo.py	Thu Mar 02 21:49:30 2017 -0800
@@ -2012,6 +2012,14 @@
     def a():
         for vfs, src, dest in renamefiles:
             try:
+                # if src and dest refer to a same file, vfs.rename is a no-op,
+                # leaving both src and dest on disk. delete dest to make sure
+                # the rename couldn't be such a no-op.
+                vfs.unlink(dest)
+            except OSError as ex:
+                if ex.errno != errno.ENOENT:
+                    raise
+            try:
                 vfs.rename(src, dest)
             except OSError: # journal file does not yet exist
                 pass