dirstate: make writing branch file out avoid ambiguity of file stat
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Fri, 03 Jun 2016 00:44:20 +0900
changeset 29302 083e107adaac
parent 29301 28f37ffc0a91
child 29303 3a2357c31d2a
dirstate: make writing branch file out avoid ambiguity of file stat Cached attribute dirstate._branch uses stat of '.hg/branch' file to examine validity of cached contents. If writing '.hg/branch' 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/branch' file out with checkambig=True. 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
@@ -367,7 +367,7 @@
 
     def setbranch(self, branch):
         self._branch = encoding.fromlocal(branch)
-        f = self._opener('branch', 'w', atomictemp=True)
+        f = self._opener('branch', 'w', atomictemp=True, checkambig=True)
         try:
             f.write(self._branch + '\n')
             f.close()