comparison tests/test-split-legacy-inline-changelog.t @ 51637:3cf9e52f5e27 stable

inline-changelog: fix a critical bug in write_pending that delete data Since a93e52f0b6ff we no longer use inline-revlog for the changelog. The goal there was to solve the lack of testing for the two variants (inline vs split) and reduce the complexity of the interaction with "diverted-write" on the changelog level. However many existing repository still have inline-changelog and we automatically move them to normal revlog as soon as we have the chances. Unfortunately This conversion is buggy and can result in the destruction of the changelog.i if hook triggers the "write pending" mechanism. The bugs comes from the "revlog splitting" logic and the "write_pending" logic stepping over each other. Ironically the change in a93e52f0b6ff aims at no longer having this kind of problem. This changesets fix this issue and add associated tests. Fixing this reveal that the transaction hooks end up not seeing the pending transaction content, because the name is not right ("changelog.i.s.a" instead of "changelog.i.s") we fix this in the next changeset.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 12 Jun 2024 02:15:20 +0200
parents
children 1721d983dd6d
comparison
equal deleted inserted replaced
51636:553eb132366f 51637:3cf9e52f5e27
1 ======================================================
2 Test operation on repository with an inlined changelog
3 ======================================================
4
5 Inlined revlog has been a bag of complexity for a long time and the combination
6 with special transaction logic on the changelog was a long source of bugs
7 poorly covered by the test suites.
8
9 We stopped doing any usage of inlined-revlog for changelog in a93e52f0b6ff,
10 upgrading legacy inlined version as soon as possible when we see them. However
11 this Mercurial does not produce such inlined-changelog that case is very poorly
12 covered in the test suites. This test file aims at covering these cases.
13
14 Double checking test data
15 =========================
16
17 We should have a repository around
18
19 $ mkdir sanity-check
20 $ cd sanity-check
21 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
22 $ cd inlined-changelog
23 $ hg root
24 $TESTTMP/sanity-check/inlined-changelog
25
26 The repository should not be corrupted initially
27
28 $ hg verify
29 checking changesets
30 checking manifests
31 crosschecking files in changesets and manifests
32 checking files
33 checking dirstate
34 checked 1 changesets with 1 changes to 1 files
35
36 The changelog of that repository MUST be inlined
37
38 $ hg debugrevlog -c | grep -E '^flags\b'
39 flags : inline
40
41 Touching that repository MUST split that inlined changelog
42
43 $ hg branch foo --quiet
44 $ hg commit -m foo --quiet
45 $ hg debugrevlog -c | grep -E '^flags\b'
46 flags : (none)
47
48 $ cd ../..
49
50 Test doing a simple commit
51 ==========================
52
53 Simple commit
54 -------------
55
56 $ mkdir simple-commit
57 $ cd simple-commit
58 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
59 $ cd inlined-changelog
60 $ hg up --quiet
61 $ hg log -GT '[{rev}] {desc}\n'
62 @ [0] first commit
63
64 $ echo b > b
65 $ hg add b
66 $ hg commit -m "second changeset"
67 $ hg verify
68 checking changesets
69 checking manifests
70 crosschecking files in changesets and manifests
71 checking files
72 checking dirstate
73 checked 2 changesets with 2 changes to 2 files
74 $ hg log -GT '[{rev}] {desc}\n'
75 @ [1] second changeset
76 |
77 o [0] first commit
78
79 $ cd ../..
80
81 Simple commit with a pretxn hook configured
82 -------------------------------------------
83
84 Before 6.7.3 this used to delete the changelog index
85
86 $ mkdir pretxnclose-commit
87 $ cd pretxnclose-commit
88 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
89 $ cat >> inlined-changelog/.hg/hgrc <<EOF
90 > [hooks]
91 > pretxnclose=hg log -r tip -T "pre-txn tip rev: {rev}\n"
92 > EOF
93 $ cd inlined-changelog
94 $ hg up --quiet
95 $ hg log -GT '[{rev}] {desc}\n'
96 @ [0] first commit
97
98 $ echo b > b
99 $ hg add b
100 $ hg commit -m "second changeset"
101 pre-txn tip rev: 1 (missing-correct-output !)
102 warning: ignoring unknown working parent 11b63e930bf2! (known-bad-output !)
103 pre-txn tip rev: 0 (known-bad-output !)
104 $ hg verify
105 checking changesets
106 checking manifests
107 crosschecking files in changesets and manifests
108 checking files
109 checking dirstate
110 checked 2 changesets with 2 changes to 2 files
111 $ hg log -GT '[{rev}] {desc}\n'
112 @ [1] second changeset
113 |
114 o [0] first commit
115
116 $ cd ../..
117
118 Test pushing to a repository with a repository revlog
119 =====================================================
120
121 Simple local push
122 -----------------
123
124 $ mkdir simple-local-push
125 $ cd simple-local-push
126 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
127 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
128 [0] first commit
129
130 $ hg clone --pull inlined-changelog client
131 requesting all changes
132 adding changesets
133 adding manifests
134 adding file changes
135 added 1 changesets with 1 changes to 1 files
136 new changesets 827f11bfd362
137 updating to branch default
138 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
139 $ cd client
140 $ echo b > b
141 $ hg add b
142 $ hg commit -m "second changeset"
143 $ hg push
144 pushing to $TESTTMP/*/inlined-changelog (glob)
145 searching for changes
146 adding changesets
147 adding manifests
148 adding file changes
149 added 1 changesets with 1 changes to 1 files
150 $ cd ..
151
152 $ hg verify -R inlined-changelog
153 checking changesets
154 checking manifests
155 crosschecking files in changesets and manifests
156 checking files
157 checking dirstate
158 checked 2 changesets with 2 changes to 2 files
159 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
160 [1] second changeset
161 [0] first commit
162 $ cd ..
163
164 Simple local push with a pretxnchangegroup hook
165 -----------------------------------------------
166
167 Before 6.7.3 this used to delete the server changelog
168
169 $ mkdir pretxnchangegroup-local-push
170 $ cd pretxnchangegroup-local-push
171 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
172 $ cat >> inlined-changelog/.hg/hgrc <<EOF
173 > [hooks]
174 > pretxnchangegroup=hg log -r tip -T "pre-txn tip rev: {rev}\n"
175 > EOF
176 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
177 [0] first commit
178
179 $ hg clone --pull inlined-changelog client
180 requesting all changes
181 adding changesets
182 adding manifests
183 adding file changes
184 added 1 changesets with 1 changes to 1 files
185 new changesets 827f11bfd362
186 updating to branch default
187 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
188 $ cd client
189 $ echo b > b
190 $ hg add b
191 $ hg commit -m "second changeset"
192 $ hg push
193 pushing to $TESTTMP/*/inlined-changelog (glob)
194 searching for changes
195 adding changesets
196 adding manifests
197 adding file changes
198 pre-txn tip rev: 1 (missing-correct-output !)
199 pre-txn tip rev: 0 (known-bad-output !)
200 added 1 changesets with 1 changes to 1 files
201 $ cd ..
202
203 $ hg verify -R inlined-changelog
204 checking changesets
205 checking manifests
206 crosschecking files in changesets and manifests
207 checking files
208 checking dirstate
209 checked 2 changesets with 2 changes to 2 files
210 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
211 [1] second changeset
212 [0] first commit
213 $ cd ..
214
215 Simple ssh push
216 -----------------
217
218 $ mkdir simple-ssh-push
219 $ cd simple-ssh-push
220 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
221 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
222 [0] first commit
223
224 $ hg clone ssh://user@dummy/"`pwd`"/inlined-changelog client
225 requesting all changes
226 adding changesets
227 adding manifests
228 adding file changes
229 added 1 changesets with 1 changes to 1 files
230 new changesets 827f11bfd362
231 updating to branch default
232 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
233 $ cd client
234 $ echo b > b
235 $ hg add b
236 $ hg commit -m "second changeset"
237 $ hg push
238 pushing to ssh://user@dummy/$TESTTMP/simple-ssh-push/inlined-changelog
239 searching for changes
240 remote: adding changesets
241 remote: adding manifests
242 remote: adding file changes
243 remote: added 1 changesets with 1 changes to 1 files
244 $ cd ..
245
246 $ hg verify -R inlined-changelog
247 checking changesets
248 checking manifests
249 crosschecking files in changesets and manifests
250 checking files
251 checking dirstate
252 checked 2 changesets with 2 changes to 2 files
253 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
254 [1] second changeset
255 [0] first commit
256 $ cd ..
257
258 Simple ssh push with a pretxnchangegroup hook
259 -----------------------------------------------
260
261 Before 6.7.3 this used to delete the server changelog
262
263 $ mkdir pretxnchangegroup-ssh-push
264 $ cd pretxnchangegroup-ssh-push
265 $ tar xf $TESTDIR/bundles/inlined-changelog.tar
266 $ cat >> inlined-changelog/.hg/hgrc <<EOF
267 > [hooks]
268 > pretxnchangegroup=hg log -r tip -T "pre-txn tip rev: {rev}\n"
269 > EOF
270 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
271 [0] first commit
272
273 $ hg clone ssh://user@dummy/"`pwd`"/inlined-changelog client
274 requesting all changes
275 adding changesets
276 adding manifests
277 adding file changes
278 added 1 changesets with 1 changes to 1 files
279 new changesets 827f11bfd362
280 updating to branch default
281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
282 $ cd client
283 $ echo b > b
284 $ hg add b
285 $ hg commit -m "second changeset"
286 $ hg push
287 pushing to ssh://user@dummy/$TESTTMP/pretxnchangegroup-ssh-push/inlined-changelog
288 searching for changes
289 remote: adding changesets
290 remote: adding manifests
291 remote: adding file changes
292 remote: pre-txn tip rev: 1 (missing-correct-output !)
293 remote: pre-txn tip rev: 0 (known-bad-output !)
294 remote: added 1 changesets with 1 changes to 1 files
295 $ cd ..
296
297 $ hg verify -R inlined-changelog
298 checking changesets
299 checking manifests
300 crosschecking files in changesets and manifests
301 checking files
302 checking dirstate
303 checked 2 changesets with 2 changes to 2 files
304 $ hg log -R inlined-changelog -T '[{rev}] {desc}\n'
305 [1] second changeset
306 [0] first commit
307 $ cd ..