# HG changeset patch # User FUJIWARA Katsunori # Date 2016-06-02 15:44:20 # Node ID 28f37ffc0a91ff6df980be729dffc41c5bc6533a # Parent f92afd23a0992ea9e7cb5519d02f8724d08c28c7 dirstate: make writing dirstate file out avoid ambiguity of file stat Cached attribute repo.dirstate uses stat of '.hg/dirstate' file to examine validity of cached contents. If writing '.hg/dirstate' file out keeps ctime, mtime and size of it, change is overlooked, and old contents cached before change isn't invalidated as expected. To avoid ambiguity of file stat, this patch writes '.hg/dirstate' file out with checkambig=True. The former diff hunk changes the code path for "dirstate.write()", and the latter changes the code path for "dirstate.savebackup()". 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 @@ -730,7 +730,7 @@ class dirstate(object): self._writedirstate, location='plain') return - st = self._opener(filename, "w", atomictemp=True) + st = self._opener(filename, "w", atomictemp=True, checkambig=True) self._writedirstate(st) def _writedirstate(self, st): @@ -1217,7 +1217,8 @@ class dirstate(object): # use '_writedirstate' instead of 'write' to write changes certainly, # because the latter omits writing out if transaction is running. # output file will be used to create backup of dirstate at this point. - self._writedirstate(self._opener(filename, "w", atomictemp=True)) + self._writedirstate(self._opener(filename, "w", atomictemp=True, + checkambig=True)) if tr: # ensure that subsequent tr.writepending returns True for