author | Martin von Zweigbergk <martinvonz@google.com> |
Tue, 18 Jan 2022 13:05:21 -0800 | |
changeset 49060 | f3aafd785e65 |
parent 48816 | bd752712ccaf |
child 48833 | dd384ad01d88 |
permissions | -rw-r--r-- |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
1 |
#testcases skip-detection fail-if-detected |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
2 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
3 |
Test situations that "should" only be reproducible: |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
4 |
- on networked filesystems, or |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
5 |
- user using `hg debuglocks` to eliminate the lock file, or |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
6 |
- something (that doesn't respect the lock file) writing to the .hg directory |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
7 |
while we're running |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
8 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
9 |
$ hg init a |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
10 |
$ cd a |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
11 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
12 |
$ cat > "$TESTTMP/waitlock_editor.sh" <<EOF |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
13 |
> [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
14 |
> f="\${WAITLOCK_FILE}" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
15 |
> start=\`date +%s\` |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
16 |
> timeout=5 |
48816
bd752712ccaf
test: use `wait-on-file` in `test-racy-mutations.t`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47225
diff
changeset
|
17 |
> $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f" |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
18 |
> if [ \$# -gt 1 ]; then |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
19 |
> cat "\$@" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
20 |
> fi |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
21 |
> EOF |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
22 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
23 |
Things behave differently if we don't already have a 00changelog.i file when |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
24 |
this all starts, so let's make one. |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
25 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
26 |
$ echo r0 > r0 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
27 |
$ hg commit -qAm 'r0' |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
28 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
29 |
Start an hg commit that will take a while |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
30 |
$ EDITOR_STARTED="$(pwd)/.editor_started" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
31 |
$ MISCHIEF_MANAGED="$(pwd)/.mischief_managed" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
32 |
$ JOBS_FINISHED="$(pwd)/.jobs_finished" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
33 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
34 |
#if fail-if-detected |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
35 |
$ cat >> .hg/hgrc << EOF |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
36 |
> [debug] |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
37 |
> revlog.verifyposition.changelog = fail |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
38 |
> EOF |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
39 |
#endif |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
40 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
41 |
$ echo foo > foo |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
42 |
$ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \ |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
43 |
> WAITLOCK_FILE="${MISCHIEF_MANAGED}" \ |
47034
a12819559ccb
tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46646
diff
changeset
|
44 |
> HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \ |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
45 |
> hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") & |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
46 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
47 |
Wait for the "editor" to actually start |
47034
a12819559ccb
tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46646
diff
changeset
|
48 |
$ WAITLOCK_FILE="${EDITOR_STARTED}" sh "$TESTTMP/waitlock_editor.sh" |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
49 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
50 |
Break the locks, and make another commit. |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
51 |
$ hg debuglocks -LW |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
52 |
$ echo bar > bar |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
53 |
$ hg commit -qAm 'r2 (bar)' bar |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
54 |
$ hg debugrevlogindex -c |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
55 |
rev linkrev nodeid p1 p2 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
56 |
0 0 222799e2f90b 000000000000 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
57 |
1 1 6f124f6007a0 222799e2f90b 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
58 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
59 |
Awaken the editor from that first commit |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
60 |
$ touch "${MISCHIEF_MANAGED}" |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
61 |
And wait for it to finish |
47034
a12819559ccb
tests: invoke some shell scripts through the shell interpreter for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
46646
diff
changeset
|
62 |
$ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh" |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
63 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
64 |
#if skip-detection |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
65 |
(Ensure there was no output) |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
66 |
$ cat .foo_commit_out |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
67 |
And observe a corrupted repository -- rev 2's linkrev is 1, which should never |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
68 |
happen for the changelog (the linkrev should always refer to itself). |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
69 |
$ hg debugrevlogindex -c |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
70 |
rev linkrev nodeid p1 p2 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
71 |
0 0 222799e2f90b 000000000000 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
72 |
1 1 6f124f6007a0 222799e2f90b 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
73 |
2 1 ac80e6205bb2 222799e2f90b 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
74 |
#endif |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
75 |
|
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
76 |
#if fail-if-detected |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
77 |
$ cat .foo_commit_out |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
78 |
transaction abort! |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
79 |
rollback completed |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
80 |
note: commit message saved in .hg/last-message.txt |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
81 |
note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
82 |
abort: 00changelog.i: file cursor at position 249, expected 121 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
83 |
And no corruption in the changelog. |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
84 |
$ hg debugrevlogindex -c |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
85 |
rev linkrev nodeid p1 p2 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
86 |
0 0 222799e2f90b 000000000000 000000000000 |
47225
906a7bcaac86
revlog: introduce a mandatory `_writing` context to update revlog content
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47034
diff
changeset
|
87 |
1 1 6f124f6007a0 222799e2f90b 000000000000 (missing-correct-output !) |
46646
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
88 |
And, because of transactions, there's none in the manifestlog either. |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
89 |
$ hg debugrevlogindex -m |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
90 |
rev linkrev nodeid p1 p2 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
91 |
0 0 7b7020262a56 000000000000 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
92 |
1 1 ad3fe36d86d9 7b7020262a56 000000000000 |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
93 |
#endif |
e9901d01d135
revlog: add a mechanism to verify expected file position before appending
Kyle Lippincott <spectral@google.com>
parents:
diff
changeset
|
94 |