Patchwork [6,of,6] phases: make writing phaseroots file out avoid ambiguity of file stat

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 2, 2016, 3:47 p.m.
Message ID <b858e69570b9ca7ab50f.1464882466@feefifofum>
Download mbox | patch
Permalink /patch/15361/
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 b858e69570b9ca7ab50f3f4379d808a6a31c582d
# Parent  acdd1b25ab08f8d8e3a3a2ed0403cd6d5dfbd099
phases: make writing phaseroots file out avoid ambiguity of file stat

Cached attribute repo._phasecache uses stat of '.hg/phaseroots' file
to examine validity of cached contents. If writing '.hg/phaseroots'
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/phaseroots'
file out with checkambig=True.

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

    https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
Augie Fackler - June 6, 2016, 3:49 p.m.
On Fri, Jun 03, 2016 at 12:47:46AM +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1464882260 -32400
> #      Fri Jun 03 00:44:20 2016 +0900
> # Node ID b858e69570b9ca7ab50f3f4379d808a6a31c582d
> # Parent  acdd1b25ab08f8d8e3a3a2ed0403cd6d5dfbd099
> phases: make writing phaseroots file out avoid ambiguity of file stat

queued this, thanks

>
> Cached attribute repo._phasecache uses stat of '.hg/phaseroots' file
> to examine validity of cached contents. If writing '.hg/phaseroots'
> 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/phaseroots'
> file out with checkambig=True.
>
> This patch is a part of "Exact Cache Validation Plan":
>
>     https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
>
> diff --git a/mercurial/phases.py b/mercurial/phases.py
> --- a/mercurial/phases.py
> +++ b/mercurial/phases.py
> @@ -251,7 +251,7 @@ class phasecache(object):
>      def write(self):
>          if not self.dirty:
>              return
> -        f = self.opener('phaseroots', 'w', atomictemp=True)
> +        f = self.opener('phaseroots', 'w', atomictemp=True, checkambig=True)
>          try:
>              self._write(f)
>          finally:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -251,7 +251,7 @@  class phasecache(object):
     def write(self):
         if not self.dirty:
             return
-        f = self.opener('phaseroots', 'w', atomictemp=True)
+        f = self.opener('phaseroots', 'w', atomictemp=True, checkambig=True)
         try:
             self._write(f)
         finally: