annotate mercurial/mergeutil.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 c1149533676b
children 2372284d9457
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30494
c1149533676b checkunresolved: move to new package to help avoid import cycles
Augie Fackler <augie@google.com>
parents: 30493
diff changeset
1 # mergeutil.py - help for merge processing in mercurial
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
2 #
4635
63b9d2deed48 Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4633
diff changeset
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
4 #
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 8210
diff changeset
5 # This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 10249
diff changeset
6 # GNU General Public License version 2 or any later version.
2874
4ec58b157265 refactor text diff/patch code.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff changeset
7
28322
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
8 from __future__ import absolute_import
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
9
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
10 from .i18n import _
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
11
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
12 from . import (
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
13 error,
ebd0e86bdf89 cmdutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 28313
diff changeset
14 )
19211
3bfd7f1e7485 summary: augment output with info from extensions
Bryan O'Sullivan <bryano@fb.com>
parents: 19129
diff changeset
15
30272
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
16 def checkunresolved(ms):
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
17 if list(ms.unresolved()):
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
18 raise error.Abort(_("unresolved merge conflicts "
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
19 "(see 'hg help resolve')"))
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
20 if ms.mdstate() != 's' or list(ms.driverresolved()):
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
21 raise error.Abort(_('driver-resolved merge conflicts'),
3d38a0bc774f cmdutil: refactor checkunresolved
timeless <timeless@mozdev.org>
parents: 30182
diff changeset
22 hint=_('run "hg resolve --all" to resolve'))