Patchwork [3,of,6,V2] transaction: apply checkambig=True only on limited files for similarity

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 4, 2017, 2:29 p.m.
Message ID <c85a31bc02311ead3ad3.1499178541@speaknoevil>
Download mbox | patch
Permalink /patch/21968/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - July 4, 2017, 2:29 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1499177627 -32400
#      Tue Jul 04 23:13:47 2017 +0900
# Node ID c85a31bc02311ead3ad37da313453d33b1881e4a
# Parent  2823a6ed15e69fd8527db5a833fe5c82d5a64074
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 "checkambigfiles".

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()
    (checkambigfiles 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.

Patch

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 = checkambigfiles and (f, l) in checkambigfiles
                 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.checkambigfiles
                     files.append(vfs(name, 'w', atomictemp=True,
-                                     checkambig=not suffix))
+                                     checkambig=checkambig))
                 genfunc(*files)
             finally:
                 for f in files: