dirstate: make writing dirstate file out avoid ambiguity of file stat
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 03 Jun 2016 00:44:20 +0900
changeset 29301 28f37ffc0a91
parent 29300 f92afd23a099
child 29302 083e107adaac
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
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Fri Jun 03 00:44:20 2016 +0900
+++ b/mercurial/dirstate.py	Fri Jun 03 00:44:20 2016 +0900
@@ -730,7 +730,7 @@
                                 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 @@
         # 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