Mercurial > hg
comparison mercurial/transaction.py @ 33279:7912404b70f2
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 04 Jul 2017 23:13:47 +0900 |
parents | 87bca10a06ed |
children | bbbbd3c30bfc |
comparison
equal
deleted
inserted
replaced
33278:87bca10a06ed | 33279:7912404b70f2 |
---|---|
70 vfs = vfsmap[l] | 70 vfs = vfsmap[l] |
71 try: | 71 try: |
72 if f and b: | 72 if f and b: |
73 filepath = vfs.join(f) | 73 filepath = vfs.join(f) |
74 backuppath = vfs.join(b) | 74 backuppath = vfs.join(b) |
75 checkambig = checkambigfiles and (f, l) in checkambigfiles | |
75 try: | 76 try: |
76 util.copyfile(backuppath, filepath, checkambig=True) | 77 util.copyfile(backuppath, filepath, checkambig=checkambig) |
77 backupfiles.append(b) | 78 backupfiles.append(b) |
78 except IOError: | 79 except IOError: |
79 report(_("failed to recover %s\n") % f) | 80 report(_("failed to recover %s\n") % f) |
80 else: | 81 else: |
81 target = f or b | 82 target = f or b |
326 try: | 327 try: |
327 for name in filenames: | 328 for name in filenames: |
328 name += suffix | 329 name += suffix |
329 if suffix: | 330 if suffix: |
330 self.registertmp(name, location=location) | 331 self.registertmp(name, location=location) |
332 checkambig = False | |
331 else: | 333 else: |
332 self.addbackup(name, location=location) | 334 self.addbackup(name, location=location) |
335 checkambig = (name, location) in self.checkambigfiles | |
333 files.append(vfs(name, 'w', atomictemp=True, | 336 files.append(vfs(name, 'w', atomictemp=True, |
334 checkambig=not suffix)) | 337 checkambig=checkambig)) |
335 genfunc(*files) | 338 genfunc(*files) |
336 finally: | 339 finally: |
337 for f in files: | 340 for f in files: |
338 f.close() | 341 f.close() |
339 return any | 342 return any |