##// END OF EJS Templates
tests: ensure a status will have non ambiguous mtime in some race test...
marmoute -
r49198:4c61c7f7 default
parent child Browse files
Show More
@@ -1,247 +1,248 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 $ hg init repo
12 $ hg init repo
13 $ cd repo
13 $ cd repo
14 $ echo a > a
14 $ echo a > a
15 $ hg add a
15 $ hg add a
16 $ hg commit -m test
16 $ hg commit -m test
17
17
18 Do we ever miss a sub-second change?:
18 Do we ever miss a sub-second change?:
19
19
20 $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
20 $ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
21 > hg update -qC 0
21 > hg update -qC 0
22 > echo b > a
22 > echo b > a
23 > hg st
23 > hg st
24 > done
24 > done
25 M a
25 M a
26 M a
26 M a
27 M a
27 M a
28 M a
28 M a
29 M a
29 M a
30 M a
30 M a
31 M a
31 M a
32 M a
32 M a
33 M a
33 M a
34 M a
34 M a
35 M a
35 M a
36 M a
36 M a
37 M a
37 M a
38 M a
38 M a
39 M a
39 M a
40 M a
40 M a
41 M a
41 M a
42 M a
42 M a
43 M a
43 M a
44 M a
44 M a
45
45
46 $ echo test > b
46 $ echo test > b
47 $ mkdir dir1
47 $ mkdir dir1
48 $ echo test > dir1/c
48 $ echo test > dir1/c
49 $ echo test > d
49 $ echo test > d
50
50
51 $ echo test > e
51 $ echo test > e
52 #if execbit
52 #if execbit
53 A directory will typically have the execute bit -- make sure it doesn't get
53 A directory will typically have the execute bit -- make sure it doesn't get
54 confused with a file with the exec bit set
54 confused with a file with the exec bit set
55 $ chmod +x e
55 $ chmod +x e
56 #endif
56 #endif
57
57
58 $ hg add b dir1 d e
58 $ hg add b dir1 d e
59 adding dir1/c
59 adding dir1/c
60 $ hg commit -m test2
60 $ hg commit -m test2
61
61
62 $ cat >> $TESTTMP/dirstaterace.py << EOF
62 $ cat >> $TESTTMP/dirstaterace.py << EOF
63 > from mercurial import (
63 > from mercurial import (
64 > context,
64 > context,
65 > extensions,
65 > extensions,
66 > )
66 > )
67 > def extsetup(ui):
67 > def extsetup(ui):
68 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
68 > extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
69 > def overridechecklookup(orig, self, files):
69 > def overridechecklookup(orig, self, files):
70 > # make an update that changes the dirstate from underneath
70 > # make an update that changes the dirstate from underneath
71 > self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
71 > self._repo.ui.system(br"sh '$TESTTMP/dirstaterace.sh'",
72 > cwd=self._repo.root)
72 > cwd=self._repo.root)
73 > return orig(self, files)
73 > return orig(self, files)
74 > EOF
74 > EOF
75
75
76 $ hg debugrebuilddirstate
76 $ hg debugrebuilddirstate
77 $ hg debugdirstate
77 $ hg debugdirstate
78 n 0 -1 unset a
78 n 0 -1 unset a
79 n 0 -1 unset b
79 n 0 -1 unset b
80 n 0 -1 unset d
80 n 0 -1 unset d
81 n 0 -1 unset dir1/c
81 n 0 -1 unset dir1/c
82 n 0 -1 unset e
82 n 0 -1 unset e
83
83
84 XXX Note that this returns M for files that got replaced by directories. This is
84 XXX Note that this returns M for files that got replaced by directories. This is
85 definitely a bug, but the fix for that is hard and the next status run is fine
85 definitely a bug, but the fix for that is hard and the next status run is fine
86 anyway.
86 anyway.
87
87
88 $ cat > $TESTTMP/dirstaterace.sh <<EOF
88 $ cat > $TESTTMP/dirstaterace.sh <<EOF
89 > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
89 > rm b && rm -r dir1 && rm d && mkdir d && rm e && mkdir e
90 > EOF
90 > EOF
91
91
92 $ sleep 1 # ensure non-ambiguous mtime
92 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
93 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py
93 M d
94 M d
94 M e
95 M e
95 ! b
96 ! b
96 ! dir1/c
97 ! dir1/c
97 $ hg debugdirstate
98 $ hg debugdirstate
98 n 644 2 * a (glob)
99 n 644 2 * a (glob)
99 n 0 -1 unset b
100 n 0 -1 unset b
100 n 0 -1 unset d
101 n 0 -1 unset d
101 n 0 -1 unset dir1/c
102 n 0 -1 unset dir1/c
102 n 0 -1 unset e
103 n 0 -1 unset e
103
104
104 $ hg status
105 $ hg status
105 ! b
106 ! b
106 ! d
107 ! d
107 ! dir1/c
108 ! dir1/c
108 ! e
109 ! e
109
110
110 $ rmdir d e
111 $ rmdir d e
111 $ hg update -C -q .
112 $ hg update -C -q .
112
113
113 Test that dirstate changes aren't written out at the end of "hg
114 Test that dirstate changes aren't written out at the end of "hg
114 status", if .hg/dirstate is already changed simultaneously before
115 status", if .hg/dirstate is already changed simultaneously before
115 acquisition of wlock in workingctx._poststatusfixup().
116 acquisition of wlock in workingctx._poststatusfixup().
116
117
117 This avoidance is important to keep consistency of dirstate in race
118 This avoidance is important to keep consistency of dirstate in race
118 condition (see issue5584 for detail).
119 condition (see issue5584 for detail).
119
120
120 $ hg parents -q
121 $ hg parents -q
121 1:* (glob)
122 1:* (glob)
122
123
123 $ hg debugrebuilddirstate
124 $ hg debugrebuilddirstate
124 $ hg debugdirstate
125 $ hg debugdirstate
125 n 0 -1 unset a
126 n 0 -1 unset a
126 n 0 -1 unset b
127 n 0 -1 unset b
127 n 0 -1 unset d
128 n 0 -1 unset d
128 n 0 -1 unset dir1/c
129 n 0 -1 unset dir1/c
129 n 0 -1 unset e
130 n 0 -1 unset e
130
131
131 $ cat > $TESTTMP/dirstaterace.sh <<EOF
132 $ cat > $TESTTMP/dirstaterace.sh <<EOF
132 > # This script assumes timetable of typical issue5584 case below:
133 > # This script assumes timetable of typical issue5584 case below:
133 > #
134 > #
134 > # 1. "hg status" loads .hg/dirstate
135 > # 1. "hg status" loads .hg/dirstate
135 > # 2. "hg status" confirms clean-ness of FILE
136 > # 2. "hg status" confirms clean-ness of FILE
136 > # 3. "hg update -C 0" updates the working directory simultaneously
137 > # 3. "hg update -C 0" updates the working directory simultaneously
137 > # (FILE is removed, and FILE is dropped from .hg/dirstate)
138 > # (FILE is removed, and FILE is dropped from .hg/dirstate)
138 > # 4. "hg status" acquires wlock
139 > # 4. "hg status" acquires wlock
139 > # (.hg/dirstate is re-loaded = no FILE entry in dirstate)
140 > # (.hg/dirstate is re-loaded = no FILE entry in dirstate)
140 > # 5. "hg status" marks FILE in dirstate as clean
141 > # 5. "hg status" marks FILE in dirstate as clean
141 > # (FILE entry is added to in-memory dirstate)
142 > # (FILE entry is added to in-memory dirstate)
142 > # 6. "hg status" writes dirstate changes into .hg/dirstate
143 > # 6. "hg status" writes dirstate changes into .hg/dirstate
143 > # (FILE entry is written into .hg/dirstate)
144 > # (FILE entry is written into .hg/dirstate)
144 > #
145 > #
145 > # To reproduce similar situation easily and certainly, #2 and #3
146 > # To reproduce similar situation easily and certainly, #2 and #3
146 > # are swapped. "hg cat" below ensures #2 on "hg status" side.
147 > # are swapped. "hg cat" below ensures #2 on "hg status" side.
147 >
148 >
148 > hg update -q -C 0
149 > hg update -q -C 0
149 > hg cat -r 1 b > b
150 > hg cat -r 1 b > b
150 > EOF
151 > EOF
151
152
152 "hg status" below should excludes "e", of which exec flag is set, for
153 "hg status" below should excludes "e", of which exec flag is set, for
153 portability of test scenario, because unsure but missing "e" is
154 portability of test scenario, because unsure but missing "e" is
154 treated differently in _checklookup() according to runtime platform.
155 treated differently in _checklookup() according to runtime platform.
155
156
156 - "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
157 - "missing(!)" on POSIX, "pctx[f].cmp(self[f])" raises ENOENT
157 - "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
158 - "modified(M)" on Windows, "self.flags(f) != pctx.flags(f)" is True
158
159
159 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
160 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug -X path:e
160 skip updating dirstate: identity mismatch
161 skip updating dirstate: identity mismatch
161 M a
162 M a
162 ! d
163 ! d
163 ! dir1/c
164 ! dir1/c
164
165
165 $ hg parents -q
166 $ hg parents -q
166 0:* (glob)
167 0:* (glob)
167 $ hg files
168 $ hg files
168 a
169 a
169 $ hg debugdirstate
170 $ hg debugdirstate
170 n * * * a (glob)
171 n * * * a (glob)
171
172
172 $ rm b
173 $ rm b
173
174
174 #if fsmonitor
175 #if fsmonitor
175
176
176 Create fsmonitor state.
177 Create fsmonitor state.
177
178
178 $ hg status
179 $ hg status
179 $ f --type .hg/fsmonitor.state
180 $ f --type .hg/fsmonitor.state
180 .hg/fsmonitor.state: file
181 .hg/fsmonitor.state: file
181
182
182 Test that invalidating fsmonitor state in the middle (which doesn't require the
183 Test that invalidating fsmonitor state in the middle (which doesn't require the
183 wlock) causes the fsmonitor update to be skipped.
184 wlock) causes the fsmonitor update to be skipped.
184 hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
185 hg debugrebuilddirstate ensures that the dirstaterace hook will be called, but
185 it also invalidates the fsmonitor state. So back it up and restore it.
186 it also invalidates the fsmonitor state. So back it up and restore it.
186
187
187 $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
188 $ mv .hg/fsmonitor.state .hg/fsmonitor.state.tmp
188 $ hg debugrebuilddirstate
189 $ hg debugrebuilddirstate
189 $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
190 $ mv .hg/fsmonitor.state.tmp .hg/fsmonitor.state
190
191
191 $ cat > $TESTTMP/dirstaterace.sh <<EOF
192 $ cat > $TESTTMP/dirstaterace.sh <<EOF
192 > rm .hg/fsmonitor.state
193 > rm .hg/fsmonitor.state
193 > EOF
194 > EOF
194
195
195 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
196 $ hg status --config extensions.dirstaterace=$TESTTMP/dirstaterace.py --debug
196 skip updating fsmonitor.state: identity mismatch
197 skip updating fsmonitor.state: identity mismatch
197 $ f .hg/fsmonitor.state
198 $ f .hg/fsmonitor.state
198 .hg/fsmonitor.state: file not found
199 .hg/fsmonitor.state: file not found
199
200
200 #endif
201 #endif
201
202
202 Set up a rebase situation for issue5581.
203 Set up a rebase situation for issue5581.
203
204
204 $ echo c2 > a
205 $ echo c2 > a
205 $ echo c2 > b
206 $ echo c2 > b
206 $ hg add b
207 $ hg add b
207 $ hg commit -m c2
208 $ hg commit -m c2
208 created new head
209 created new head
209 $ echo c3 >> a
210 $ echo c3 >> a
210 $ hg commit -m c3
211 $ hg commit -m c3
211 $ hg update 2
212 $ hg update 2
212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 $ echo c4 >> a
214 $ echo c4 >> a
214 $ echo c4 >> b
215 $ echo c4 >> b
215 $ hg commit -m c4
216 $ hg commit -m c4
216 created new head
217 created new head
217
218
218 Configure a merge tool that runs status in the middle of the rebase. The goal of
219 Configure a merge tool that runs status in the middle of the rebase. The goal of
219 the status call is to trigger a potential bug if fsmonitor's state is written
220 the status call is to trigger a potential bug if fsmonitor's state is written
220 even though the wlock is held by another process. The output of 'hg status' in
221 even though the wlock is held by another process. The output of 'hg status' in
221 the merge tool goes to /dev/null because we're more interested in the results of
222 the merge tool goes to /dev/null because we're more interested in the results of
222 'hg status' run after the rebase.
223 'hg status' run after the rebase.
223
224
224 $ cat >> $TESTTMP/mergetool-race.sh << EOF
225 $ cat >> $TESTTMP/mergetool-race.sh << EOF
225 > echo "custom merge tool"
226 > echo "custom merge tool"
226 > printf "c2\nc3\nc4\n" > \$1
227 > printf "c2\nc3\nc4\n" > \$1
227 > hg --cwd "$TESTTMP/repo" status > /dev/null
228 > hg --cwd "$TESTTMP/repo" status > /dev/null
228 > echo "custom merge tool end"
229 > echo "custom merge tool end"
229 > EOF
230 > EOF
230 $ cat >> $HGRCPATH << EOF
231 $ cat >> $HGRCPATH << EOF
231 > [extensions]
232 > [extensions]
232 > rebase =
233 > rebase =
233 > [merge-tools]
234 > [merge-tools]
234 > test.executable=sh
235 > test.executable=sh
235 > test.args=$TESTTMP/mergetool-race.sh \$output
236 > test.args=$TESTTMP/mergetool-race.sh \$output
236 > EOF
237 > EOF
237
238
238 $ hg rebase -s . -d 3 --tool test
239 $ hg rebase -s . -d 3 --tool test
239 rebasing 4:b08445fd6b2a tip "c4"
240 rebasing 4:b08445fd6b2a tip "c4"
240 merging a
241 merging a
241 custom merge tool
242 custom merge tool
242 custom merge tool end
243 custom merge tool end
243 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
244 saved backup bundle to $TESTTMP/repo/.hg/strip-backup/* (glob)
244
245
245 This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
246 This hg status should be empty, whether or not fsmonitor is enabled (issue5581).
246
247
247 $ hg status
248 $ hg status
General Comments 0
You need to be logged in to leave comments. Login now