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