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

mail settings
Submitter Katsunori FUJIWARA
Date June 29, 2017, 4:53 p.m.
Message ID <e3a1739ee331b182c973.1498755192@speaknoevil>
Download mbox | patch
Permalink /patch/21827/
State Accepted
Headers show


Katsunori FUJIWARA - June 29, 2017, 4:53 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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
-                    util.copyfile(backuppath, filepath, checkambig=True)
+                    util.copyfile(backuppath, filepath, checkambig=checkambig)
                 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
                         self.addbackup(name, location=location)
+                        checkambig = (name, location) in self.noambigstatfiles
                     files.append(vfs(name, 'w', atomictemp=True,
-                                     checkambig=not suffix))
+                                     checkambig=checkambig))
                 for f in files: