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