transaction: apply checkambig=True only on limited files for similarity
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Tue, 04 Jul 2017 23:13:47 +0900
changeset 33279 7912404b70f2
parent 33278 87bca10a06ed
child 33280 646352291f5b
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.
mercurial/transaction.py
--- a/mercurial/transaction.py	Tue Jul 04 23:13:46 2017 +0900
+++ b/mercurial/transaction.py	Tue Jul 04 23:13:47 2017 +0900
@@ -72,8 +72,9 @@
             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 @@
                     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: