comparison mercurial/localrepo.py @ 33278:87bca10a06ed

transaction: avoid file stat ambiguity only for files in blacklist Advancing mtime by os.utime() fails for EPERM, if the target file is owned by another. bff5ccbe5ead and related changes made some code paths give advancing mtime up in such case, to fix issue5418. This causes file stat ambiguity (again), if it is owned by another. https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan To avoid file stat ambiguity in such case, especially for .hg/dirstate, ed66ec39933f made vfs.rename() copy the target file, and advance mtime of renamed one again, if EPERM (see issue5584 for detail). But straightforward "copy if EPERM" isn't reasonable for truncation of append-only files at rollbacking, because rollbacking might cost much for truncation of many filelogs, even though filelogs aren't filecache-ed. Therefore, this patch introduces blacklist "checkambigfiles", and avoids file stat ambiguity only for files specified in this blacklist. This patch consists of two parts below, which should be applied at once in order to avoid regression. - specify 'checkambig=True' at vfs.open(mode='a') in _playback() according to checkambigfiles - invoke _playback() with checkambigfiles - add transaction.__init__() checkambigfiles argument, for _abort() - make localrepo instantiate transaction with _cachedfiles - add rollback() checkambigfiles argument, for "hg rollback/recover" - make localrepo invoke rollback() with _cachedfiles After this patch, straightforward "copy if EPERM" will be reasonable at closing the file opened with checkambig=True, because this policy is applied only on files, which are listed in blacklist "checkambigfiles".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 04 Jul 2017 23:13:46 +0900
parents 4470508eb6f2
children 36a415b5a4b2
comparison
equal deleted inserted replaced
33277:4470508eb6f2 33278:87bca10a06ed
1096 "journal", 1096 "journal",
1097 "undo", 1097 "undo",
1098 aftertrans(renames), 1098 aftertrans(renames),
1099 self.store.createmode, 1099 self.store.createmode,
1100 validator=validate, 1100 validator=validate,
1101 releasefn=releasefn) 1101 releasefn=releasefn,
1102 checkambigfiles=_cachedfiles)
1102 tr.changes['revs'] = set() 1103 tr.changes['revs'] = set()
1103 tr.changes['obsmarkers'] = set() 1104 tr.changes['obsmarkers'] = set()
1104 1105
1105 tr.hookargs['txnid'] = txnid 1106 tr.hookargs['txnid'] = txnid
1106 # note: writing the fncache only during finalize mean that the file is 1107 # note: writing the fncache only during finalize mean that the file is
1162 if self.svfs.exists("journal"): 1163 if self.svfs.exists("journal"):
1163 self.ui.status(_("rolling back interrupted transaction\n")) 1164 self.ui.status(_("rolling back interrupted transaction\n"))
1164 vfsmap = {'': self.svfs, 1165 vfsmap = {'': self.svfs,
1165 'plain': self.vfs,} 1166 'plain': self.vfs,}
1166 transaction.rollback(self.svfs, vfsmap, "journal", 1167 transaction.rollback(self.svfs, vfsmap, "journal",
1167 self.ui.warn) 1168 self.ui.warn,
1169 checkambigfiles=_cachedfiles)
1168 self.invalidate() 1170 self.invalidate()
1169 return True 1171 return True
1170 else: 1172 else:
1171 self.ui.warn(_("no interrupted transaction available\n")) 1173 self.ui.warn(_("no interrupted transaction available\n"))
1172 return False 1174 return False
1218 return 0 1220 return 0
1219 1221
1220 parents = self.dirstate.parents() 1222 parents = self.dirstate.parents()
1221 self.destroying() 1223 self.destroying()
1222 vfsmap = {'plain': self.vfs, '': self.svfs} 1224 vfsmap = {'plain': self.vfs, '': self.svfs}
1223 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn) 1225 transaction.rollback(self.svfs, vfsmap, 'undo', ui.warn,
1226 checkambigfiles=_cachedfiles)
1224 if self.vfs.exists('undo.bookmarks'): 1227 if self.vfs.exists('undo.bookmarks'):
1225 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True) 1228 self.vfs.rename('undo.bookmarks', 'bookmarks', checkambig=True)
1226 if self.svfs.exists('undo.phaseroots'): 1229 if self.svfs.exists('undo.phaseroots'):
1227 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True) 1230 self.svfs.rename('undo.phaseroots', 'phaseroots', checkambig=True)
1228 self.invalidate() 1231 self.invalidate()