##// 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
@@ -30,17 +30,23 b" outside of hg's control."
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
@@ -52,3 +58,32 b' so hg status correctly shows a as clean.'
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