Mercurial > hg
annotate tests/test-addremove.t @ 46607:e9901d01d135
revlog: add a mechanism to verify expected file position before appending
If someone uses `hg debuglocks`, or some non-hg process writes to the .hg
directory without respecting the locks, or if the repo's on a networked
filesystem, it's possible for the revlog code to write out corrupted data.
The form of this corruption can vary depending on what data was written and how
that happened. We are in the "networked filesystem" case (though I've had users
also do this to themselves with the "`hg debuglocks`" scenario), and most often
see this with the changelog. What ends up happening is we produce two items
(let's call them rev1 and rev2) in the .i file that have the same linkrev,
baserev, and offset into the .d file, while the data in the .d file is appended
properly. rev2's compressed_size is accurate for rev2, but when we go to
decompress the data in the .d file, we use the offset that's recorded in the
index file, which is the same as rev1, and attempt to decompress
rev2.compressed_size bytes of rev1's data. This usually does not succeed. :)
When using inline data, this also fails, though I haven't investigated why too
closely. This shows up as a "patch decode" error. I believe what's happening
there is that we're basically ignoring the offset field, getting the data
properly, but since baserev != rev, it thinks this is a delta based on rev
(instead of a full text) and can't actually apply it as such.
For now, I'm going to make this an optional component and default it to entirely
off. I may increase the default severity of this in the future, once I've
enabled it for my users and we gain more experience with it. Luckily, most of my
users have a versioned filesystem and can roll back to before the corruption has
been written, it's just a hassle to do so and not everyone knows how (so it's a
support burden). Users on other filesystems will not have that luxury, and this
can cause them to have a corrupted repository that they are unlikely to know how
to resolve, and they'll see this as a data-loss event. Refusing to create the
corruption is a much better user experience.
This mechanism is not perfect. There may be false-negatives (racy writes that
are not detected). There should not be any false-positives (non-racy writes that
are detected as such). This is not a mechanism that makes putting a repo on a
networked filesystem "safe" or "supported", just *less* likely to cause
corruption.
Differential Revision: https://phab.mercurial-scm.org/D9952
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Wed, 03 Feb 2021 16:33:10 -0800 |
parents | 824b687ff6af |
children |
rev | line source |
---|---|
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
1 $ hg init rep |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
2 $ cd rep |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
3 $ mkdir dir |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
4 $ touch foo dir/bar |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
5 $ hg -v addremove |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
6 adding dir/bar |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
7 adding foo |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
11850
diff
changeset
|
8 $ hg -v commit -m "add 1" |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
9 committing files: |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
10 dir/bar |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
11 foo |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
12 committing manifest |
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
13 committing changelog |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
11850
diff
changeset
|
14 committed changeset 0:6f7f953567a2 |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
15 $ cd dir/ |
16874
8017ac7a0e8f
test-addremove: remove bits about con.xml
Adrian Buehlmann <adrian@cadifra.com>
parents:
15444
diff
changeset
|
16 $ touch ../foo_2 bar_2 |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
17 $ hg -v addremove |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
18 adding dir/bar_2 |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
19 adding foo_2 |
12156
4c94b6d0fb1c
tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents:
11850
diff
changeset
|
20 $ hg -v commit -m "add 2" |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
21 committing files: |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
22 dir/bar_2 |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
23 foo_2 |
23749
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
24 committing manifest |
a387b0390082
localrepo: show headline notes in commitctx before showing filenames
Mads Kiilerich <madski@unity3d.com>
parents:
23535
diff
changeset
|
25 committing changelog |
16874
8017ac7a0e8f
test-addremove: remove bits about con.xml
Adrian Buehlmann <adrian@cadifra.com>
parents:
15444
diff
changeset
|
26 committed changeset 1:e65414bf35c5 |
23259
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
27 $ cd .. |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
28 $ hg forget foo |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
29 $ hg -v addremove |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
30 adding foo |
23534
83bbedc16b3f
addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents:
23427
diff
changeset
|
31 $ hg forget foo |
33340
dd050fc04cc9
test-addremove: conditionalize output instead of tests
Matt Harbison <matt_harbison@yahoo.com>
parents:
24180
diff
changeset
|
32 |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23749
diff
changeset
|
33 $ hg -v addremove nonexistent |
35230
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33340
diff
changeset
|
34 nonexistent: $ENOENT$ |
23534
83bbedc16b3f
addremove: warn when addremove fails to operate on a named path
Matt Harbison <matt_harbison@yahoo.com>
parents:
23427
diff
changeset
|
35 [1] |
33340
dd050fc04cc9
test-addremove: conditionalize output instead of tests
Matt Harbison <matt_harbison@yahoo.com>
parents:
24180
diff
changeset
|
36 |
23259
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
37 $ cd .. |
2958
ff3ea21a981a
addremove: add -s/--similarity option
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1933
diff
changeset
|
38 |
23427
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
39 $ hg init subdir |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
40 $ cd subdir |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
41 $ mkdir dir |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
42 $ cd dir |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
43 $ touch a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
44 $ hg addremove 'glob:*.py' |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
45 adding a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
46 $ hg forget a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
47 $ hg addremove -I 'glob:*.py' |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
48 adding a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
49 $ hg forget a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
50 $ hg addremove |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
51 adding dir/a.py |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
52 $ cd .. |
3778884197f0
addremove: print relative paths when called with -I/-X (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
23259
diff
changeset
|
53 |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
54 $ hg init sim |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
55 $ cd sim |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
56 $ echo a > a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
57 $ echo a >> a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
58 $ echo a >> a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
59 $ echo c > c |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
60 $ hg commit -Ama |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
61 adding a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
62 adding c |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
63 $ mv a b |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
64 $ rm c |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
65 $ echo d > d |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
66 $ hg addremove -n -s 50 # issue 1696 |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
67 removing a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
68 adding b |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
69 removing c |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
70 adding d |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
71 recording removal of a as rename to b (100% similar) |
39088
ad88726d6982
addremove: add labels for messages about added and removed files
Boris Feld <boris.feld@octobus.net>
parents:
35230
diff
changeset
|
72 $ hg addremove -ns 50 --color debug |
40367
824b687ff6af
addremove: add "ui." prefix to message color keys
Yuya Nishihara <yuya@tcha.org>
parents:
39088
diff
changeset
|
73 [ui.addremove.removed ui.status|removing a] |
824b687ff6af
addremove: add "ui." prefix to message color keys
Yuya Nishihara <yuya@tcha.org>
parents:
39088
diff
changeset
|
74 [ui.addremove.added ui.status|adding b] |
824b687ff6af
addremove: add "ui." prefix to message color keys
Yuya Nishihara <yuya@tcha.org>
parents:
39088
diff
changeset
|
75 [ui.addremove.removed ui.status|removing c] |
824b687ff6af
addremove: add "ui." prefix to message color keys
Yuya Nishihara <yuya@tcha.org>
parents:
39088
diff
changeset
|
76 [ui.addremove.added ui.status|adding d] |
39088
ad88726d6982
addremove: add labels for messages about added and removed files
Boris Feld <boris.feld@octobus.net>
parents:
35230
diff
changeset
|
77 [ ui.status|recording removal of a as rename to b (100% similar)] |
11850
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
78 $ hg addremove -s 50 |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
79 removing a |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
80 adding b |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
81 removing c |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
82 adding d |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
83 recording removal of a as rename to b (100% similar) |
54dbf16b401f
tests: unify test-addremove
Martin Geisler <mg@lazybytes.net>
parents:
8990
diff
changeset
|
84 $ hg commit -mb |
23259
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
85 $ cp b c |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
86 $ hg forget b |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
87 $ hg addremove -s 50 |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
88 adding b |
9f4778027bc2
addremove: add back forgotten files (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
16912
diff
changeset
|
89 adding c |
23535
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
90 |
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
91 $ rm c |
33340
dd050fc04cc9
test-addremove: conditionalize output instead of tests
Matt Harbison <matt_harbison@yahoo.com>
parents:
24180
diff
changeset
|
92 |
24180
d8e0c591781c
spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents:
23749
diff
changeset
|
93 $ hg ci -A -m "c" nonexistent |
35230
feecfefeba25
tests: add a substitution for ENOENT/ERROR_FILE_NOT_FOUND messages
Matt Harbison <matt_harbison@yahoo.com>
parents:
33340
diff
changeset
|
94 nonexistent: $ENOENT$ |
23535
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
95 abort: failed to mark all new/missing files as added/removed |
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
96 [255] |
33340
dd050fc04cc9
test-addremove: conditionalize output instead of tests
Matt Harbison <matt_harbison@yahoo.com>
parents:
24180
diff
changeset
|
97 |
23535
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
98 $ hg st |
72c23fa4f52f
commit: abort if --addremove is specified, but fails
Matt Harbison <matt_harbison@yahoo.com>
parents:
23534
diff
changeset
|
99 ! c |
16912
6ef3107c661e
tests: cleanup of tests that got lost in their own nested directories
Mads Kiilerich <mads@kiilerich.com>
parents:
16874
diff
changeset
|
100 $ cd .. |