# HG changeset patch # User FUJIWARA Katsunori # Date 2016-06-12 20:11:56 # Node ID bebe7d1c38c855e97f51dfb8ad808f9c9c483533 # Parent 35861cc1076ecb3d1552d34b6f2311349c150070 dirstate: make restoring from backup avoid ambiguity of file stat File .hg/dirstate is restored by renaming from backup in failure inside scopes below. If renaming keeps ctime, mtime and size of a file, restoring is overlooked, and old contents cached before restoring isn't invalidated as expected. - dirstateguard scope (from '.hg/dirstate.SUFFIX') - transaction scope (from '.hg/journal.dirstate') To avoid ambiguity of file stat at restoring, this patch invokes vfs.rename() with checkambig=True. This patch is a part of "Exact Cache Validation Plan": https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -1243,7 +1243,8 @@ class dirstate(object): self.invalidate() filename = self._actualfilename(tr) # using self._filename to avoid having "pending" in the backup filename - self._opener.rename(prefix + self._filename + suffix, filename) + self._opener.rename(prefix + self._filename + suffix, filename, + checkambig=True) def clearbackup(self, tr, suffix='', prefix=''): '''Clear backup file with suffix'''