Show More
@@ -1,101 +1,94 b'' | |||||
1 | #testcases skip-detection fail-if-detected |
|
1 | #testcases skip-detection fail-if-detected | |
2 |
|
2 | |||
3 | Test situations that "should" only be reproducible: |
|
3 | Test situations that "should" only be reproducible: | |
4 | - on networked filesystems, or |
|
4 | - on networked filesystems, or | |
5 | - user using `hg debuglocks` to eliminate the lock file, or |
|
5 | - user using `hg debuglocks` to eliminate the lock file, or | |
6 | - something (that doesn't respect the lock file) writing to the .hg directory |
|
6 | - something (that doesn't respect the lock file) writing to the .hg directory | |
7 | while we're running |
|
7 | while we're running | |
8 |
|
8 | |||
9 | $ hg init a |
|
9 | $ hg init a | |
10 | $ cd a |
|
10 | $ cd a | |
11 |
|
11 | |||
12 | $ cat > "$TESTTMP/waitlock_editor.sh" <<EOF |
|
12 | $ cat > "$TESTTMP/waitlock_editor.sh" <<EOF | |
13 | > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}" |
|
13 | > [ -n "\${WAITLOCK_ANNOUNCE:-}" ] && touch "\${WAITLOCK_ANNOUNCE}" | |
14 | > f="\${WAITLOCK_FILE}" |
|
14 | > f="\${WAITLOCK_FILE}" | |
15 | > start=\`date +%s\` |
|
15 | > start=\`date +%s\` | |
16 | > timeout=5 |
|
16 | > timeout=5 | |
17 | > while [ \\( ! -f \$f \\) -a \\( ! -L \$f \\) ]; do |
|
17 | > $RUNTESTDIR/testlib/wait-on-file "\$timeout" "\$f" | |
18 | > now=\`date +%s\` |
|
|||
19 | > if [ "\`expr \$now - \$start\`" -gt \$timeout ]; then |
|
|||
20 | > echo "timeout: \$f was not created in \$timeout seconds (it is now \$(date +%s))" |
|
|||
21 | > exit 1 |
|
|||
22 | > fi |
|
|||
23 | > sleep 0.1 |
|
|||
24 | > done |
|
|||
25 |
> if [ \$# -gt |
|
18 | > if [ \$# -gt 1 ]; then | |
26 |
> cat |
|
19 | > cat "\$@" | |
27 | > fi |
|
20 | > fi | |
28 | > EOF |
|
21 | > EOF | |
29 |
|
22 | |||
30 |
|
|
23 | Things behave differently if we don't already have a 00changelog.i file when | |
31 |
this all starts, so let' |
|
24 | this all starts, so let's make one. | |
32 |
|
25 | |||
33 |
$ |
|
26 | $ echo r0 > r0 | |
34 |
$ |
|
27 | $ hg commit -qAm 'r0' | |
35 |
|
28 | |||
36 |
|
|
29 | Start an hg commit that will take a while | |
37 | $ EDITOR_STARTED="$(pwd)/.editor_started" |
|
30 | $ EDITOR_STARTED="$(pwd)/.editor_started" | |
38 | $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed" |
|
31 | $ MISCHIEF_MANAGED="$(pwd)/.mischief_managed" | |
39 | $ JOBS_FINISHED="$(pwd)/.jobs_finished" |
|
32 | $ JOBS_FINISHED="$(pwd)/.jobs_finished" | |
40 |
|
33 | |||
41 | #if fail-if-detected |
|
34 | #if fail-if-detected | |
42 | $ cat >> .hg/hgrc << EOF |
|
35 | $ cat >> .hg/hgrc << EOF | |
43 | > [debug] |
|
36 | > [debug] | |
44 | > revlog.verifyposition.changelog = fail |
|
37 | > revlog.verifyposition.changelog = fail | |
45 | > EOF |
|
38 | > EOF | |
46 | #endif |
|
39 | #endif | |
47 |
|
40 | |||
48 |
$ echo |
|
41 | $ echo foo > foo | |
49 | $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \ |
|
42 | $ (WAITLOCK_ANNOUNCE="${EDITOR_STARTED}" \ | |
50 | > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \ |
|
43 | > WAITLOCK_FILE="${MISCHIEF_MANAGED}" \ | |
51 | > HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \ |
|
44 | > HGEDITOR="sh $TESTTMP/waitlock_editor.sh" \ | |
52 |
> hg |
|
45 | > hg commit -qAm 'r1 (foo)' --edit foo > .foo_commit_out 2>&1 ; touch "${JOBS_FINISHED}") & | |
53 |
|
46 | |||
54 |
Wait |
|
47 | Wait for the "editor" to actually start | |
55 |
$ |
|
48 | $ WAITLOCK_FILE="${EDITOR_STARTED}" sh "$TESTTMP/waitlock_editor.sh" | |
56 |
|
49 | |||
57 |
|
|
50 | Break the locks, and make another commit. | |
58 |
$ |
|
51 | $ hg debuglocks -LW | |
59 |
$ |
|
52 | $ echo bar > bar | |
60 |
$ |
|
53 | $ hg commit -qAm 'r2 (bar)' bar | |
61 |
$ |
|
54 | $ hg debugrevlogindex -c | |
62 |
|
|
55 | rev linkrev nodeid p1 p2 | |
63 |
|
|
56 | 0 0 222799e2f90b 000000000000 000000000000 | |
64 |
|
|
57 | 1 1 6f124f6007a0 222799e2f90b 000000000000 | |
65 |
|
58 | |||
66 |
|
|
59 | Awaken the editor from that first commit | |
67 |
$ |
|
60 | $ touch "${MISCHIEF_MANAGED}" | |
68 |
|
|
61 | And wait for it to finish | |
69 |
$ |
|
62 | $ WAITLOCK_FILE="${JOBS_FINISHED}" sh "$TESTTMP/waitlock_editor.sh" | |
70 |
|
63 | |||
71 | #if skip-detection |
|
64 | #if skip-detection | |
72 |
(Ensure |
|
65 | (Ensure there was no output) | |
73 |
|
|
66 | $ cat .foo_commit_out | |
74 |
|
|
67 | And observe a corrupted repository -- rev 2's linkrev is 1, which should never | |
75 | happen for the changelog (the linkrev should always refer to itself). |
|
68 | happen for the changelog (the linkrev should always refer to itself). | |
76 | $ hg debugrevlogindex -c |
|
69 | $ hg debugrevlogindex -c | |
77 | rev linkrev nodeid p1 p2 |
|
70 | rev linkrev nodeid p1 p2 | |
78 | 0 0 222799e2f90b 000000000000 000000000000 |
|
71 | 0 0 222799e2f90b 000000000000 000000000000 | |
79 | 1 1 6f124f6007a0 222799e2f90b 000000000000 |
|
72 | 1 1 6f124f6007a0 222799e2f90b 000000000000 | |
80 | 2 1 ac80e6205bb2 222799e2f90b 000000000000 |
|
73 | 2 1 ac80e6205bb2 222799e2f90b 000000000000 | |
81 | #endif |
|
74 | #endif | |
82 |
|
75 | |||
83 | #if fail-if-detected |
|
76 | #if fail-if-detected | |
84 | $ cat .foo_commit_out |
|
77 | $ cat .foo_commit_out | |
85 | transaction abort! |
|
78 | transaction abort! | |
86 | rollback completed |
|
79 | rollback completed | |
87 | note: commit message saved in .hg/last-message.txt |
|
80 | note: commit message saved in .hg/last-message.txt | |
88 |
note: use ' |
|
81 | note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it | |
89 | abort: 00changelog.i: file cursor at position 249, expected 121 |
|
82 | abort: 00changelog.i: file cursor at position 249, expected 121 | |
90 | And no corruption in the changelog. |
|
83 | And no corruption in the changelog. | |
91 | $ hg debugrevlogindex -c |
|
84 | $ hg debugrevlogindex -c | |
92 | rev linkrev nodeid p1 p2 |
|
85 | rev linkrev nodeid p1 p2 | |
93 | 0 0 222799e2f90b 000000000000 000000000000 |
|
86 | 0 0 222799e2f90b 000000000000 000000000000 | |
94 | 1 1 6f124f6007a0 222799e2f90b 000000000000 (missing-correct-output !) |
|
87 | 1 1 6f124f6007a0 222799e2f90b 000000000000 (missing-correct-output !) | |
95 |
And, because of transactions, there' |
|
88 | And, because of transactions, there's none in the manifestlog either. | |
96 |
$ |
|
89 | $ hg debugrevlogindex -m | |
97 |
|
|
90 | rev linkrev nodeid p1 p2 | |
98 |
|
|
91 | 0 0 7b7020262a56 000000000000 000000000000 | |
99 |
|
|
92 | 1 1 ad3fe36d86d9 7b7020262a56 000000000000 | |
100 | #endif |
|
93 | #endif | |
101 |
|
94 |
General Comments 0
You need to be logged in to leave comments.
Login now