[PATCH 2 of 6] transaction: avoid ambiguity of file stat at closing transaction

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jun 2 11:47:42 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1464882260 -32400
#      Fri Jun 03 00:44:20 2016 +0900
# Node ID 1a3b8c0c2808510d887270c0f2cbb7912369008d
# Parent  14bb84173e73e00d5d761d00f14c4ff6c2b23afd
transaction: avoid ambiguity of file stat at closing transaction

Files below, which might be changed at closing transaction, are used
to examine validity of cached properties. If changing keeps ctime,
mtime and size of a file, change is overlooked, and old contents
cached before change isn't invalidated as expected.

  - .hg/bookmarks
  - .hg/dirstate
  - .hg/phaseroots

To avoid ambiguity of file stat, this patch writes files out with
checkambig=True at closing transaction.

checkambig becomes True only at closing (= 'not suffix'), because stat
information of '.pending' file isn't used to examine validity of
cached properties.

This patch is a part of "Exact Cache Validation Plan":

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -311,7 +311,8 @@ class transaction(object):
                         self.registertmp(name, location=location)
                     else:
                         self.addbackup(name, location=location)
-                    files.append(vfs(name, 'w', atomictemp=True))
+                    files.append(vfs(name, 'w', atomictemp=True,
+                                     checkambig=not suffix))
                 genfunc(*files)
             finally:
                 for f in files:


More information about the Mercurial-devel mailing list