[PATCH 5 of 8] transaction: apply checkambig=True only on limited files for similarity

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Jun 29 12:53:12 EDT 2017


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1498754869 -32400
#      Fri Jun 30 01:47:49 2017 +0900
# Node ID e3a1739ee331b182c973ce679828b29e880db5ee
# Parent  d4d47784511456e6cf77b194822f23586e052312
transaction: apply checkambig=True only on limited files for similarity

Now, transaction can determine whether avoidance of file stat
ambiguity is needed for each files, by blacklist "noambigstatfiles".

For similarity to truncation in _playback(), this patch apply
checkambig=True only on limited files in code paths below.

  - restoring files by util.copyfile(), in _playback()
    (noambigstatfiles itself is examined at first, because it as a
    keyword argument might be None)

  - writing files at finalization of transaction, in _generatefiles()

This patch reduces cost of checking stat at writing out and restoring
files, which aren't filecache-ed.

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -72,8 +72,9 @@ def _playback(journal, report, opener, v
             if f and b:
                 filepath = vfs.join(f)
                 backuppath = vfs.join(b)
+                checkambig = noambigstatfiles and (f, l) in noambigstatfiles
                 try:
-                    util.copyfile(backuppath, filepath, checkambig=True)
+                    util.copyfile(backuppath, filepath, checkambig=checkambig)
                     backupfiles.append(b)
                 except IOError:
                     report(_("failed to recover %s\n") % f)
@@ -328,10 +329,12 @@ class transaction(object):
                     name += suffix
                     if suffix:
                         self.registertmp(name, location=location)
+                        checkambig = False
                     else:
                         self.addbackup(name, location=location)
+                        checkambig = (name, location) in self.noambigstatfiles
                     files.append(vfs(name, 'w', atomictemp=True,
-                                     checkambig=not suffix))
+                                     checkambig=checkambig))
                 genfunc(*files)
             finally:
                 for f in files:


More information about the Mercurial-devel mailing list