localrepo: make restoring from backup at rollback avoid ambiguity of file stat
Rollback of previous transaction restores contents of files below by
renaming from 'undo.*' file. If renaming keeps ctime, mtime and size
of a file, restoring is overlooked, and old contents cached before
restoring isn't invalidated as expected.
- .hg/bookmarks
- .hg/phaseroots
To avoid ambiguity of file stat at restoring, this patch invokes
vfs.rename() with checkambig=True.
BTW, .hg/dirstate is also restored at rollback. But it is restored by
dirstate.restorebackup(), and previous patch already made it invoke
vfs.rename() with checkambig=True.
This patch is a part of "Exact Cache Validation Plan":
https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
--- a/mercurial/localrepo.py Mon Jun 13 05:11:56 2016 +0900
+++ b/mercurial/localrepo.py Mon Jun 13 05:11:56 2016 +0900
@@ -1172,9 +1172,9 @@
vfsmap = {'plain': self.vfs, '': self.svfs}
transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn)
if self.vfs.exists('undo.bookmarks'):
- self.vfs.rename('undo.bookmarks', 'bookmarks')
+ self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
if self.svfs.exists('undo.phaseroots'):
- self.svfs.rename('undo.phaseroots', 'phaseroots')
+ self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
self.invalidate()
parentgone = (parents[0] not in self.changelog.nodemap or