##// END OF EJS Templates
dirstate-v2: display a possible issue with transaction...
marmoute -
r50361:486b8a38 stable
parent child Browse files
Show More
@@ -1,215 +1,253 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 > use-dirstate-v2=1
7 7 > [storage]
8 8 > dirstate-v2.slow-path=allow
9 9 > EOF
10 10 #endif
11 11
12 12 ------ Test dirstate._dirs refcounting
13 13
14 14 $ hg init t
15 15 $ cd t
16 16 $ mkdir -p a/b/c/d
17 17 $ touch a/b/c/d/x
18 18 $ touch a/b/c/d/y
19 19 $ touch a/b/c/d/z
20 20 $ hg ci -Am m
21 21 adding a/b/c/d/x
22 22 adding a/b/c/d/y
23 23 adding a/b/c/d/z
24 24 $ hg mv a z
25 25 moving a/b/c/d/x to z/b/c/d/x
26 26 moving a/b/c/d/y to z/b/c/d/y
27 27 moving a/b/c/d/z to z/b/c/d/z
28 28
29 29 Test name collisions
30 30
31 31 $ rm z/b/c/d/x
32 32 $ mkdir z/b/c/d/x
33 33 $ touch z/b/c/d/x/y
34 34 $ hg add z/b/c/d/x/y
35 35 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
36 36 [255]
37 37 $ rm -rf z/b/c/d
38 38 $ touch z/b/c/d
39 39 $ hg add z/b/c/d
40 40 abort: directory 'z/b/c/d' already in dirstate
41 41 [255]
42 42
43 43 $ cd ..
44 44
45 45 Issue1790: dirstate entry locked into unset if file mtime is set into
46 46 the future
47 47
48 48 Prepare test repo:
49 49
50 50 $ hg init u
51 51 $ cd u
52 52 $ echo a > a
53 53 $ hg add
54 54 adding a
55 55 $ hg ci -m1
56 56
57 57 Set mtime of a into the future:
58 58
59 59 $ touch -t 203101011200 a
60 60
61 61 Status must not set a's entry to unset (issue1790):
62 62
63 63 $ hg status
64 64 $ hg debugstate
65 65 n 644 2 2031-01-01 12:00:00 a
66 66
67 67 Test modulo storage/comparison of absurd dates:
68 68
69 69 #if no-aix
70 70 $ touch -t 195001011200 a
71 71 $ hg st
72 72 $ hg debugstate
73 73 n 644 2 2018-01-19 15:14:08 a
74 74 #endif
75 75
76 76 Verify that exceptions during a dirstate change leave the dirstate
77 77 coherent (issue4353)
78 78
79 79 $ cat > ../dirstateexception.py <<EOF
80 80 > from mercurial import (
81 81 > error,
82 82 > extensions,
83 83 > mergestate as mergestatemod,
84 84 > )
85 85 >
86 86 > def wraprecordupdates(*args):
87 87 > raise error.Abort(b"simulated error while recording dirstateupdates")
88 88 >
89 89 > def reposetup(ui, repo):
90 90 > extensions.wrapfunction(mergestatemod, 'recordupdates',
91 91 > wraprecordupdates)
92 92 > EOF
93 93
94 94 $ hg rm a
95 95 $ hg commit -m 'rm a'
96 96 $ echo "[extensions]" >> .hg/hgrc
97 97 $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc
98 98 $ hg up 0
99 99 abort: simulated error while recording dirstateupdates
100 100 [255]
101 101 $ hg log -r . -T '{rev}\n'
102 102 1
103 103 $ hg status
104 104 ? a
105 105
106 106 #if dirstate-v2
107 107 Check that folders that are prefixes of others do not throw the packer into an
108 108 infinite loop.
109 109
110 110 $ cd ..
111 111 $ hg init infinite-loop
112 112 $ cd infinite-loop
113 113 $ mkdir hgext3rd hgext
114 114 $ touch hgext3rd/__init__.py hgext/zeroconf.py
115 115 $ hg commit -Aqm0
116 116
117 117 $ hg st -c
118 118 C hgext/zeroconf.py
119 119 C hgext3rd/__init__.py
120 120
121 121 $ cd ..
122 122
123 123 Check that the old dirstate data file is removed correctly and the new one is
124 124 valid.
125 125
126 126 $ dirstate_data_files () {
127 127 > find .hg -maxdepth 1 -name "dirstate.*"
128 128 > }
129 129
130 130 $ find_dirstate_uuid () {
131 131 > hg debugstate --docket | grep uuid | sed 's/.*uuid: \(.*\)/\1/'
132 132 > }
133 133
134 134 $ find_dirstate_data_size () {
135 135 > hg debugstate --docket | grep 'size of dirstate data' | sed 's/.*size of dirstate data: \(.*\)/\1/'
136 136 > }
137 137
138 138 $ dirstate_uuid_has_not_changed () {
139 139 > # Non-Rust always rewrites the whole dirstate
140 140 > if [ $# -eq 1 ] || ([ -n "$HGMODULEPOLICY" ] && [ -z "${HGMODULEPOLICY##*rust*}" ]) || [ -n "$RHG_INSTALLED_AS_HG" ]; then
141 141 > test $current_uid = $(find_dirstate_uuid)
142 142 > else
143 143 > echo "not testing because using Python implementation"
144 144 > fi
145 145 > }
146 146
147 147 $ cd ..
148 148 $ hg init append-mostly
149 149 $ cd append-mostly
150 150 $ mkdir dir dir2
151 151 $ touch dir/a dir/b dir/c dir/d dir/e dir2/f
152 152 $ hg commit -Aqm initial
153 153 $ hg st
154 154 $ dirstate_data_files | wc -l
155 155 *1 (re)
156 156 $ current_uid=$(find_dirstate_uuid)
157 157
158 158 Nothing changes here
159 159
160 160 $ hg st
161 161 $ dirstate_data_files | wc -l
162 162 *1 (re)
163 163 $ dirstate_uuid_has_not_changed
164 164 not testing because using Python implementation (no-rust no-rhg !)
165 165
166 166 Trigger an append with a small change
167 167
168 168 $ current_data_size=$(find_dirstate_data_size)
169 169 $ rm dir2/f
170 170 $ hg st
171 171 ! dir2/f
172 172 $ dirstate_data_files | wc -l
173 173 *1 (re)
174 174 $ dirstate_uuid_has_not_changed
175 175 not testing because using Python implementation (no-rust no-rhg !)
176 176 $ new_data_size=$(find_dirstate_data_size)
177 177 $ [ "$current_data_size" -eq "$new_data_size" ]; echo $?
178 178 0 (no-rust no-rhg !)
179 179 1 (rust !)
180 180 1 (no-rust rhg !)
181 181
182 182 Unused bytes counter is non-0 when appending
183 183 $ touch file
184 184 $ hg add file
185 185 $ current_uid=$(find_dirstate_uuid)
186 186
187 187 Trigger a rust/rhg run which updates the unused bytes value
188 188 $ hg st
189 189 A file
190 190 ! dir2/f
191 191 $ dirstate_data_files | wc -l
192 192 *1 (re)
193 193 $ dirstate_uuid_has_not_changed
194 194 not testing because using Python implementation (no-rust no-rhg !)
195 195
196 196 $ hg debugstate --docket | grep unused
197 197 number of unused bytes: 0 (no-rust no-rhg !)
198 198 number of unused bytes: [1-9]\d* (re) (rhg no-rust !)
199 199 number of unused bytes: [1-9]\d* (re) (rust no-rhg !)
200 200 number of unused bytes: [1-9]\d* (re) (rust rhg !)
201 201
202 202 Delete most of the dirstate to trigger a non-append
203 203 $ hg rm dir/a dir/b dir/c dir/d
204 204 $ dirstate_data_files | wc -l
205 205 *1 (re)
206 206 $ dirstate_uuid_has_not_changed also-if-python
207 207 [1]
208 208
209 209 Check that unused bytes counter is reset when creating a new docket
210 210
211 211 $ hg debugstate --docket | grep unused
212 212 number of unused bytes: 0
213 213
214 214 #endif
215 215
216 Transaction compatibility
217 -------------------------
218
219 The transaction preserves the dirstate.
220 We should make sure all of it (docket + data) is preserved
221
222 #if dirstate-v2
223 $ hg commit -m 'bli'
224 #endif
225
226 $ hg update --quiet
227 $ hg revert --all --quiet
228 $ rm -f a
229 $ echo foo > foo
230 $ hg add foo
231 $ hg commit -m foo
232
233 #if dirstate-v2
234 $ uid=$(find_dirstate_uuid)
235 $ touch bar
236 $ while [ uid = $(find_dirstate_uuid) ]; do
237 > hg add bar;
238 > hg remove bar;
239 > done;
240 $ rm bar
241 #endif
242 $ hg rollback
243 repository tip rolled back to revision 1 (undo commit)
244 working directory now based on revision 1
245
246 #if dirstate-v1
247 $ hg status
248 A foo
249 #else
250 $ hg status
251 abort: $ENOENT$: '*/.hg/dirstate.*' (glob) (known-bad-output !)
252 [255]
253 #endif
General Comments 0
You need to be logged in to leave comments. Login now