##// END OF EJS Templates
test: add test for a former race resulting in bad dirstate...
Valentin Gatien-Baron -
r49290:bc6547f6 default
parent child Browse files
Show More
@@ -1,54 +1,89 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [format]
5 > [format]
6 > exp-rc-dirstate-v2=1
6 > exp-rc-dirstate-v2=1
7 > [storage]
7 > [storage]
8 > dirstate-v2.slow-path=allow
8 > dirstate-v2.slow-path=allow
9 > EOF
9 > EOF
10 #endif
10 #endif
11
11
12 Checking the size/permissions/file-type of files stored in the
12 Checking the size/permissions/file-type of files stored in the
13 dirstate after an update where the files are changed concurrently
13 dirstate after an update where the files are changed concurrently
14 outside of hg's control.
14 outside of hg's control.
15
15
16 $ hg init repo
16 $ hg init repo
17 $ cd repo
17 $ cd repo
18 $ echo a > a
18 $ echo a > a
19 $ hg commit -qAm _
19 $ hg commit -qAm _
20 $ echo aa > a
20 $ echo aa > a
21 $ hg commit -m _
21 $ hg commit -m _
22 # this sleep is there to ensure current time has -at-least- one second away
22 # this sleep is there to ensure current time has -at-least- one second away
23 # from the current time. It ensure the mtime is not ambiguous. If the test
23 # from the current time. It ensure the mtime is not ambiguous. If the test
24 # "sleep" longer this will be fine.
24 # "sleep" longer this will be fine.
25 # It is not used to synchronise parallele operation so it is "fine" to use it.
25 # It is not used to synchronise parallele operation so it is "fine" to use it.
26 $ sleep 1
26 $ sleep 1
27 $ hg status
27 $ hg status
28
28
29 $ hg debugdirstate --no-dates
29 $ hg debugdirstate --no-dates
30 n 644 3 (set |unset) a (re)
30 n 644 3 (set |unset) a (re)
31
31
32 $ cat >> $TESTTMP/dirstaterace.py << EOF
32 $ cat >> $TESTTMP/dirstaterace.py << EOF
33 > import time
33 > from mercurial import (
34 > from mercurial import (
35 > commit,
34 > extensions,
36 > extensions,
35 > merge,
37 > merge,
36 > )
38 > )
37 > def extsetup(ui):
39 > def extsetup(ui):
38 > extensions.wrapfunction(merge, 'applyupdates', wrap)
40 > extensions.wrapfunction(merge, 'applyupdates', wrap(0))
39 > def wrap(orig, *args, **kwargs):
41 > extensions.wrapfunction(commit, 'commitctx', wrap(1))
40 > res = orig(*args, **kwargs)
42 > def wrap(duration):
41 > with open("a", "w"):
43 > def new(orig, *args, **kwargs):
42 > pass # just truncate the file
44 > res = orig(*args, **kwargs)
43 > return res
45 > with open("a", "w"):
46 > pass # just truncate the file
47 > time.sleep(duration)
48 > return res
49 > return new
44 > EOF
50 > EOF
45
51
46 Do an update where file 'a' is changed between hg writing it to disk
52 Do an update where file 'a' is changed between hg writing it to disk
47 and hg writing the dirstate. The dirstate is correct nonetheless, and
53 and hg writing the dirstate. The dirstate is correct nonetheless, and
48 so hg status correctly shows a as clean.
54 so hg status correctly shows a as clean.
49
55
50 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
56 $ hg up -r 0 --config extensions.race=$TESTTMP/dirstaterace.py
51 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
57 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
52 $ hg debugdirstate --no-dates
58 $ hg debugdirstate --no-dates
53 n 644 2 (set |unset) a (re)
59 n 644 2 (set |unset) a (re)
54 $ echo a > a; hg status; hg diff
60 $ echo a > a; hg status; hg diff
61
62 Do a commit where file 'a' is changed between hg committing its new
63 revision into the repository, and the writing of the dirstate.
64
65 This used to results in a corrupted dirstate (size did not match committed size).
66
67 $ echo aaa > a; hg commit -qm _
68 $ hg merge -qr 1; hg resolve -m; rm a.orig
69 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
70 (no more unresolved files)
71 $ cat a
72 <<<<<<< working copy: be46f74ce38d - test: _
73 aaa
74 =======
75 aa
76 >>>>>>> merge rev: eb3fc6c17aa3 - test: _
77 $ hg debugdirstate --no-dates
78 m 0 -2 (set |unset) a (re)
79 $ hg commit -m _ --config extensions.race=$TESTTMP/dirstaterace.py
80 $ hg debugdirstate --no-dates
81 n 0 -1 unset a
82 $ cat a | wc -c
83 *0 (re)
84 $ hg cat -r . a | wc -c
85 *105 (re)
86 $ hg status; hg diff --stat
87 M a
88 a | 5 -----
89 1 files changed, 0 insertions(+), 5 deletions(-)
General Comments 0
You need to be logged in to leave comments. Login now