transaction: avoid ambiguity of file stat at restoring from backup
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Mon, 13 Jun 2016 05:11:56 +0900
changeset 29353 a9ccd9af48ef
parent 29352 37c7f9fb7040
child 29354 af849596752c
transaction: avoid ambiguity of file stat at restoring from backup In some cases below, copying from backup is used to restore original contents of a file, which is backuped via addfilegenerator(). If copying keeps ctime, mtime and size of a file, restoring is overlooked, and old contents cached before restoring isn't invalidated as expected. - failure of transaction (from '.hg/journal.backup.*') - rollback of previous transaction (from '.hg/undo.backup.*') To avoid ambiguity of file stat at restoring, this patch invokes util.copyfile() with checkambig=True. This patch is a part of "Exact Cache Validation Plan": https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
mercurial/transaction.py
--- a/mercurial/transaction.py	Mon Jun 13 05:11:56 2016 +0900
+++ b/mercurial/transaction.py	Mon Jun 13 05:11:56 2016 +0900
@@ -72,7 +72,7 @@
                 filepath = vfs.join(f)
                 backuppath = vfs.join(b)
                 try:
-                    util.copyfile(backuppath, filepath)
+                    util.copyfile(backuppath, filepath, checkambig=True)
                     backupfiles.append(b)
                 except IOError:
                     report(_("failed to recover %s\n") % f)