[PATCH 2 of 4] localrepo: make restoring from backup at rollback avoid ambiguity of file stat

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Jun 12 16:15:19 EDT 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1465762316 -32400
#      Mon Jun 13 05:11:56 2016 +0900
# Node ID e49ecef9ba4fa398e5597d7412b94d2f397698ee
# Parent  f4cf29d6dd97a6cf319cbdeef08dc84b2418819a
localrepo: make restoring from backup at rollback avoid ambiguity of file stat

Rollback of previous transaction restores contents of files below by
renaming from 'undo.*' file. If renaming keeps ctime, mtime and size
of a file, restoring is overlooked, and old contents cached before
restoring isn't invalidated as expected.

  - .hg/bookmarks
  - .hg/phaseroots

To avoid ambiguity of file stat at restoring, this patch invokes
vfs.rename() with checkambig=True.

BTW, .hg/dirstate is also restored at rollback. But it is restored by
dirstate.restorebackup(), and previous patch already made it invoke
vfs.rename() with checkambig=True.

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

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

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1172,9 +1172,9 @@ class localrepository(object):
         vfsmap = {'plain': self.vfs, '': self.svfs}
         transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn)
         if self.vfs.exists('undo.bookmarks'):
-            self.vfs.rename('undo.bookmarks', 'bookmarks')
+            self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
         if self.svfs.exists('undo.phaseroots'):
-            self.svfs.rename('undo.phaseroots', 'phaseroots')
+            self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
         self.invalidate()
 
         parentgone = (parents[0] not in self.changelog.nodemap or


More information about the Mercurial-devel mailing list