--- a/mercurial/dirstate.py Fri Oct 20 05:53:33 2017 -0700
+++ b/mercurial/dirstate.py Fri Oct 20 05:53:35 2017 -0700
@@ -1187,7 +1187,11 @@
# changes of dirstate out after restoring from backup file
self.invalidate()
filename = self._actualfilename(tr)
- self._opener.rename(backupname, filename, checkambig=True)
+ o = self._opener
+ if util.samefile(o.join(backupname), o.join(filename)):
+ o.unlink(backupname)
+ else:
+ o.rename(backupname, filename, checkambig=True)
def clearbackup(self, tr, backupname):
'''Clear backup file'''