Patchwork [5,of,6] dirstate: make writing branch file out avoid ambiguity of file stat

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 2, 2016, 3:47 p.m.
Message ID <acdd1b25ab08f8d8e3a3.1464882465@feefifofum>
Download mbox | patch
Permalink /patch/15365/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 2, 2016, 3:47 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1464882260 -32400
#      Fri Jun 03 00:44:20 2016 +0900
# Node ID acdd1b25ab08f8d8e3a3a2ed0403cd6d5dfbd099
# Parent  9d61f363d6a40d860e609fc56313cd21c5830413
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

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -367,7 +367,7 @@  class dirstate(object):
 
     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()