Show More
@@ -1,319 +1,355 b'' | |||
|
1 | 1 | =================================== |
|
2 | 2 | Test the persistent on-disk nodemap |
|
3 | 3 | =================================== |
|
4 | 4 | |
|
5 | 5 | $ hg init test-repo |
|
6 | 6 | $ cd test-repo |
|
7 | 7 | $ cat << EOF >> .hg/hgrc |
|
8 | 8 | > [experimental] |
|
9 | 9 | > exp-persistent-nodemap=yes |
|
10 | 10 | > [devel] |
|
11 | 11 | > persistent-nodemap=yes |
|
12 | 12 | > EOF |
|
13 | 13 | $ hg debugbuilddag .+5000 |
|
14 | 14 | $ hg debugnodemap --metadata |
|
15 | 15 | uid: ???????????????? (glob) |
|
16 | 16 | tip-rev: 5000 |
|
17 | 17 | tip-node: 06ddac466af534d365326c13c3879f97caca3cb1 |
|
18 | 18 | data-length: 122880 |
|
19 | 19 | data-unused: 0 |
|
20 | 20 | $ f --size .hg/store/00changelog.n |
|
21 | 21 | .hg/store/00changelog.n: size=70 |
|
22 | 22 | |
|
23 | 23 | Simple lookup works |
|
24 | 24 | |
|
25 | 25 | $ ANYNODE=`hg log --template '{node|short}\n' --rev tip` |
|
26 | 26 | $ hg log -r "$ANYNODE" --template '{rev}\n' |
|
27 | 27 | 5000 |
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | #if rust |
|
31 | 31 | |
|
32 | 32 | $ f --sha256 .hg/store/00changelog-*.nd |
|
33 | 33 | .hg/store/00changelog-????????????????.nd: sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6 (glob) |
|
34 | 34 | $ hg debugnodemap --dump-new | f --sha256 --size |
|
35 | 35 | size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6 |
|
36 | 36 | $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size |
|
37 | 37 | size=122880, sha256=1e38e9ffaa45cad13f15c1a9880ad606f4241e8beea2f61b4d5365abadfb55f6 |
|
38 | 38 | 0000: 00 00 00 76 00 00 01 65 00 00 00 95 00 00 01 34 |...v...e.......4| |
|
39 | 39 | 0010: 00 00 00 19 00 00 01 69 00 00 00 ab 00 00 00 4b |.......i.......K| |
|
40 | 40 | 0020: 00 00 00 07 00 00 01 4c 00 00 00 f8 00 00 00 8f |.......L........| |
|
41 | 41 | 0030: 00 00 00 c0 00 00 00 a7 00 00 00 89 00 00 01 46 |...............F| |
|
42 | 42 | 0040: 00 00 00 92 00 00 01 bc 00 00 00 71 00 00 00 ac |...........q....| |
|
43 | 43 | 0050: 00 00 00 af 00 00 00 b4 00 00 00 34 00 00 01 ca |...........4....| |
|
44 | 44 | 0060: 00 00 00 23 00 00 01 45 00 00 00 2d 00 00 00 b2 |...#...E...-....| |
|
45 | 45 | 0070: 00 00 00 56 00 00 01 0f 00 00 00 4e 00 00 02 4c |...V.......N...L| |
|
46 | 46 | 0080: 00 00 00 e7 00 00 00 cd 00 00 01 5b 00 00 00 78 |...........[...x| |
|
47 | 47 | 0090: 00 00 00 e3 00 00 01 8e 00 00 00 4f 00 00 00 b1 |...........O....| |
|
48 | 48 | 00a0: 00 00 00 30 00 00 00 11 00 00 00 25 00 00 00 d2 |...0.......%....| |
|
49 | 49 | 00b0: 00 00 00 ec 00 00 00 69 00 00 01 2b 00 00 01 2e |.......i...+....| |
|
50 | 50 | 00c0: 00 00 00 aa 00 00 00 15 00 00 00 3a 00 00 01 4e |...........:...N| |
|
51 | 51 | 00d0: 00 00 00 4d 00 00 00 9d 00 00 00 8e 00 00 00 a4 |...M............| |
|
52 | 52 | 00e0: 00 00 00 c3 00 00 00 eb 00 00 00 29 00 00 00 ad |...........)....| |
|
53 | 53 | 00f0: 00 00 01 3a 00 00 01 32 00 00 00 04 00 00 00 53 |...:...2.......S| |
|
54 | 54 | |
|
55 | 55 | |
|
56 | 56 | #else |
|
57 | 57 | |
|
58 | 58 | $ f --sha256 .hg/store/00changelog-*.nd |
|
59 | 59 | .hg/store/00changelog-????????????????.nd: sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 (glob) |
|
60 | 60 | $ hg debugnodemap --dump-new | f --sha256 --size |
|
61 | 61 | size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 |
|
62 | 62 | $ hg debugnodemap --dump-disk | f --sha256 --bytes=256 --hexdump --size |
|
63 | 63 | size=122880, sha256=b961925120e1c9bc345c199b2cc442abc477029fdece37ef9d99cbe59c0558b7 |
|
64 | 64 | 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
65 | 65 | 0010: ff ff ff ff ff ff ff ff ff ff fa c2 ff ff ff ff |................| |
|
66 | 66 | 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
67 | 67 | 0030: ff ff ff ff ff ff ed b3 ff ff ff ff ff ff ff ff |................| |
|
68 | 68 | 0040: ff ff ff ff ff ff ee 34 00 00 00 00 ff ff ff ff |.......4........| |
|
69 | 69 | 0050: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
70 | 70 | 0060: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
71 | 71 | 0070: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
72 | 72 | 0080: ff ff ff ff ff ff f8 50 ff ff ff ff ff ff ff ff |.......P........| |
|
73 | 73 | 0090: ff ff ff ff ff ff ff ff ff ff ec c7 ff ff ff ff |................| |
|
74 | 74 | 00a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
75 | 75 | 00b0: ff ff ff ff ff ff fa be ff ff f2 fc ff ff ff ff |................| |
|
76 | 76 | 00c0: ff ff ff ff ff ff ef ea ff ff ff ff ff ff f9 17 |................| |
|
77 | 77 | 00d0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
78 | 78 | 00e0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
79 | 79 | 00f0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| |
|
80 | 80 | |
|
81 | 81 | #endif |
|
82 | 82 | |
|
83 | 83 | $ hg debugnodemap --check |
|
84 | 84 | revision in index: 5001 |
|
85 | 85 | revision in nodemap: 5001 |
|
86 | 86 | |
|
87 | 87 | add a new commit |
|
88 | 88 | |
|
89 | 89 | $ hg up |
|
90 | 90 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | 91 | $ echo foo > foo |
|
92 | 92 | $ hg add foo |
|
93 | 93 | $ hg ci -m 'foo' |
|
94 | 94 | |
|
95 | 95 | #if no-pure no-rust |
|
96 | 96 | $ hg debugnodemap --metadata |
|
97 | 97 | uid: ???????????????? (glob) |
|
98 | 98 | tip-rev: 5001 |
|
99 | 99 | tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49 |
|
100 | 100 | data-length: 122880 |
|
101 | 101 | data-unused: 0 |
|
102 | 102 | #else |
|
103 | 103 | $ hg debugnodemap --metadata |
|
104 | 104 | uid: ???????????????? (glob) |
|
105 | 105 | tip-rev: 5001 |
|
106 | 106 | tip-node: 2dd9b5258caa46469ff07d4a3da1eb3529a51f49 |
|
107 | 107 | data-length: 123072 |
|
108 | 108 | data-unused: 192 |
|
109 | 109 | #endif |
|
110 | 110 | |
|
111 | 111 | $ f --size .hg/store/00changelog.n |
|
112 | 112 | .hg/store/00changelog.n: size=70 |
|
113 | 113 | |
|
114 | 114 | (The pure code use the debug code that perform incremental update, the C code reencode from scratch) |
|
115 | 115 | |
|
116 | 116 | #if pure |
|
117 | 117 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
118 | 118 | .hg/store/00changelog-????????????????.nd: size=123072, sha256=136472751566c8198ff09e306a7d2f9bd18bd32298d614752b73da4d6df23340 (glob) |
|
119 | 119 | #endif |
|
120 | 120 | |
|
121 | 121 | #if rust |
|
122 | 122 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
123 | 123 | .hg/store/00changelog-????????????????.nd: size=123072, sha256=ccc8a43310ace13812fcc648683e259346754ef934c12dd238cf9b7fadfe9a4b (glob) |
|
124 | 124 | #endif |
|
125 | 125 | |
|
126 | 126 | #if no-pure no-rust |
|
127 | 127 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
128 | 128 | .hg/store/00changelog-????????????????.nd: size=122880, sha256=bfafebd751c4f6d116a76a37a1dee2a251747affe7efbcc4f4842ccc746d4db9 (glob) |
|
129 | 129 | #endif |
|
130 | 130 | |
|
131 | 131 | $ hg debugnodemap --check |
|
132 | 132 | revision in index: 5002 |
|
133 | 133 | revision in nodemap: 5002 |
|
134 | 134 | |
|
135 | 135 | Test code path without mmap |
|
136 | 136 | --------------------------- |
|
137 | 137 | |
|
138 | 138 | $ echo bar > bar |
|
139 | 139 | $ hg add bar |
|
140 | 140 | $ hg ci -m 'bar' --config experimental.exp-persistent-nodemap.mmap=no |
|
141 | 141 | |
|
142 | 142 | $ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=yes |
|
143 | 143 | revision in index: 5003 |
|
144 | 144 | revision in nodemap: 5003 |
|
145 | 145 | $ hg debugnodemap --check --config experimental.exp-persistent-nodemap.mmap=no |
|
146 | 146 | revision in index: 5003 |
|
147 | 147 | revision in nodemap: 5003 |
|
148 | 148 | |
|
149 | 149 | |
|
150 | 150 | #if pure |
|
151 | 151 | $ hg debugnodemap --metadata |
|
152 | 152 | uid: ???????????????? (glob) |
|
153 | 153 | tip-rev: 5002 |
|
154 | 154 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
155 | 155 | data-length: 123328 |
|
156 | 156 | data-unused: 384 |
|
157 | 157 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
158 | 158 | .hg/store/00changelog-????????????????.nd: size=123328, sha256=10d26e9776b6596af0f89143a54eba8cc581e929c38242a02a7b0760698c6c70 (glob) |
|
159 | 159 | #endif |
|
160 | 160 | #if rust |
|
161 | 161 | $ hg debugnodemap --metadata |
|
162 | 162 | uid: ???????????????? (glob) |
|
163 | 163 | tip-rev: 5002 |
|
164 | 164 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
165 | 165 | data-length: 123328 |
|
166 | 166 | data-unused: 384 |
|
167 | 167 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
168 | 168 | .hg/store/00changelog-????????????????.nd: size=123328, sha256=081eec9eb6708f2bf085d939b4c97bc0b6762bc8336bc4b93838f7fffa1516bf (glob) |
|
169 | 169 | #endif |
|
170 | 170 | #if no-pure no-rust |
|
171 | 171 | $ hg debugnodemap --metadata |
|
172 | 172 | uid: ???????????????? (glob) |
|
173 | 173 | tip-rev: 5002 |
|
174 | 174 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
175 | 175 | data-length: 122944 |
|
176 | 176 | data-unused: 0 |
|
177 | 177 | $ f --sha256 .hg/store/00changelog-*.nd --size |
|
178 | 178 | .hg/store/00changelog-????????????????.nd: size=122944, sha256=755976b22b64ab680401b45395953504e64e7fa8c31ac570f58dee21e15f9bc0 (glob) |
|
179 | 179 | #endif |
|
180 | 180 | |
|
181 | 181 | Test force warming the cache |
|
182 | 182 | |
|
183 | 183 | $ rm .hg/store/00changelog.n |
|
184 | 184 | $ hg debugnodemap --metadata |
|
185 | 185 | $ hg debugupdatecache |
|
186 | 186 | #if pure |
|
187 | 187 | $ hg debugnodemap --metadata |
|
188 | 188 | uid: ???????????????? (glob) |
|
189 | 189 | tip-rev: 5002 |
|
190 | 190 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
191 | 191 | data-length: 122944 |
|
192 | 192 | data-unused: 0 |
|
193 | 193 | #else |
|
194 | 194 | $ hg debugnodemap --metadata |
|
195 | 195 | uid: ???????????????? (glob) |
|
196 | 196 | tip-rev: 5002 |
|
197 | 197 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
198 | 198 | data-length: 122944 |
|
199 | 199 | data-unused: 0 |
|
200 | 200 | #endif |
|
201 | 201 | |
|
202 | 202 | Check out of sync nodemap |
|
203 | 203 | ========================= |
|
204 | 204 | |
|
205 | 205 | First copy old data on the side. |
|
206 | 206 | |
|
207 | 207 | $ mkdir ../tmp-copies |
|
208 | 208 | $ cp .hg/store/00changelog-????????????????.nd .hg/store/00changelog.n ../tmp-copies |
|
209 | 209 | |
|
210 | 210 | Nodemap lagging behind |
|
211 | 211 | ---------------------- |
|
212 | 212 | |
|
213 | 213 | make a new commit |
|
214 | 214 | |
|
215 | 215 | $ echo bar2 > bar |
|
216 | 216 | $ hg ci -m 'bar2' |
|
217 | 217 | $ NODE=`hg log -r tip -T '{node}\n'` |
|
218 | 218 | $ hg log -r "$NODE" -T '{rev}\n' |
|
219 | 219 | 5003 |
|
220 | 220 | |
|
221 | 221 | If the nodemap is lagging behind, it can catch up fine |
|
222 | 222 | |
|
223 | 223 | $ hg debugnodemap --metadata |
|
224 | 224 | uid: ???????????????? (glob) |
|
225 | 225 | tip-rev: 5003 |
|
226 | 226 | tip-node: 5c049e9c4a4af159bdcd65dce1b6bf303a0da6cf |
|
227 | 227 | data-length: 123200 (pure !) |
|
228 | 228 | data-length: 123200 (rust !) |
|
229 | 229 | data-length: 122944 (no-rust no-pure !) |
|
230 | 230 | data-unused: 256 (pure !) |
|
231 | 231 | data-unused: 256 (rust !) |
|
232 | 232 | data-unused: 0 (no-rust no-pure !) |
|
233 | 233 | $ cp -f ../tmp-copies/* .hg/store/ |
|
234 | 234 | $ hg debugnodemap --metadata |
|
235 | 235 | uid: ???????????????? (glob) |
|
236 | 236 | tip-rev: 5002 |
|
237 | 237 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
238 | 238 | data-length: 122944 |
|
239 | 239 | data-unused: 0 |
|
240 | 240 | $ hg log -r "$NODE" -T '{rev}\n' |
|
241 | 241 | 5003 |
|
242 | 242 | |
|
243 | 243 | changelog altered |
|
244 | 244 | ----------------- |
|
245 | 245 | |
|
246 | 246 | If the nodemap is not gated behind a requirements, an unaware client can alter |
|
247 | 247 | the repository so the revlog used to generate the nodemap is not longer |
|
248 | 248 | compatible with the persistent nodemap. We need to detect that. |
|
249 | 249 | |
|
250 | 250 | $ hg up "$NODE~5" |
|
251 | 251 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
252 | 252 | $ echo bar > babar |
|
253 | 253 | $ hg add babar |
|
254 | 254 | $ hg ci -m 'babar' |
|
255 | 255 | created new head |
|
256 | 256 | $ OTHERNODE=`hg log -r tip -T '{node}\n'` |
|
257 | 257 | $ hg log -r "$OTHERNODE" -T '{rev}\n' |
|
258 | 258 | 5004 |
|
259 | 259 | |
|
260 | 260 | $ hg --config extensions.strip= strip --rev "$NODE~1" --no-backup |
|
261 | 261 | |
|
262 | 262 | the nodemap should detect the changelog have been tampered with and recover. |
|
263 | 263 | |
|
264 | 264 | $ hg debugnodemap --metadata |
|
265 | 265 | uid: ???????????????? (glob) |
|
266 | 266 | tip-rev: 5002 |
|
267 | 267 | tip-node: 42bf3068c7ddfdfded53c4eb11d02266faeebfee |
|
268 | 268 | data-length: 123456 (pure !) |
|
269 | 269 | data-length: 246464 (rust !) |
|
270 | 270 | data-length: 123008 (no-pure no-rust !) |
|
271 | 271 | data-unused: 448 (pure !) |
|
272 | 272 | data-unused: 123904 (rust !) |
|
273 | 273 | data-unused: 0 (no-pure no-rust !) |
|
274 | 274 | |
|
275 | 275 | $ cp -f ../tmp-copies/* .hg/store/ |
|
276 | 276 | $ hg debugnodemap --metadata |
|
277 | 277 | uid: ???????????????? (glob) |
|
278 | 278 | tip-rev: 5002 |
|
279 | 279 | tip-node: 6ce944fafcee85af91f29ea5b51654cc6101ad7e |
|
280 | 280 | data-length: 122944 |
|
281 | 281 | data-unused: 0 |
|
282 | 282 | $ hg log -r "$OTHERNODE" -T '{rev}\n' |
|
283 | 283 | 5002 |
|
284 | 284 | |
|
285 | 285 | Check transaction related property |
|
286 | 286 | ================================== |
|
287 | 287 | |
|
288 | 288 | An up to date nodemap should be available to shell hooks, |
|
289 | 289 | |
|
290 | 290 | $ echo dsljfl > a |
|
291 | 291 | $ hg add a |
|
292 | 292 | $ hg ci -m a |
|
293 | 293 | $ hg debugnodemap --metadata |
|
294 | 294 | uid: ???????????????? (glob) |
|
295 | 295 | tip-rev: 5003 |
|
296 | 296 | tip-node: c91af76d172f1053cca41b83f7c2e4e514fe2bcf |
|
297 | 297 | data-length: 123008 |
|
298 | 298 | data-unused: 0 |
|
299 | 299 | $ echo babar2 > babar |
|
300 | 300 | $ hg ci -m 'babar2' --config "hooks.pretxnclose.nodemap-test=hg debugnodemap --metadata" |
|
301 | 301 | uid: ???????????????? (glob) |
|
302 | 302 | tip-rev: 5004 |
|
303 | 303 | tip-node: ba87cd9559559e4b91b28cb140d003985315e031 |
|
304 | 304 | data-length: 123328 (pure !) |
|
305 | 305 | data-length: 123328 (rust !) |
|
306 | 306 | data-length: 123136 (no-pure no-rust !) |
|
307 | 307 | data-unused: 192 (pure !) |
|
308 | 308 | data-unused: 192 (rust !) |
|
309 | 309 | data-unused: 0 (no-pure no-rust !) |
|
310 | 310 | $ hg debugnodemap --metadata |
|
311 | 311 | uid: ???????????????? (glob) |
|
312 | 312 | tip-rev: 5004 |
|
313 | 313 | tip-node: ba87cd9559559e4b91b28cb140d003985315e031 |
|
314 | 314 | data-length: 123328 (pure !) |
|
315 | 315 | data-length: 123328 (rust !) |
|
316 | 316 | data-length: 123136 (no-pure no-rust !) |
|
317 | 317 | data-unused: 192 (pure !) |
|
318 | 318 | data-unused: 192 (rust !) |
|
319 | 319 | data-unused: 0 (no-pure no-rust !) |
|
320 | ||
|
321 | Another process does not see the pending nodemap content during run. | |
|
322 | ||
|
323 | $ PATH=$RUNTESTDIR/testlib/:$PATH | |
|
324 | $ echo qpoasp > a | |
|
325 | $ hg ci -m a2 \ | |
|
326 | > --config "hooks.pretxnclose=wait-on-file 20 sync-repo-read sync-txn-pending" \ | |
|
327 | > --config "hooks.txnclose=touch sync-txn-close" > output.txt 2>&1 & | |
|
328 | ||
|
329 | (read the repository while the commit transaction is pending) | |
|
330 | ||
|
331 | $ wait-on-file 20 sync-txn-pending && \ | |
|
332 | > hg debugnodemap --metadata && \ | |
|
333 | > wait-on-file 20 sync-txn-close sync-repo-read | |
|
334 | uid: ???????????????? (glob) | |
|
335 | tip-rev: 5004 | |
|
336 | tip-node: ba87cd9559559e4b91b28cb140d003985315e031 | |
|
337 | data-length: 123328 (pure !) | |
|
338 | data-length: 123328 (rust !) | |
|
339 | data-length: 123136 (no-pure no-rust !) | |
|
340 | data-unused: 192 (pure !) | |
|
341 | data-unused: 192 (rust !) | |
|
342 | data-unused: 0 (no-pure no-rust !) | |
|
343 | $ hg debugnodemap --metadata | |
|
344 | uid: ???????????????? (glob) | |
|
345 | tip-rev: 5005 | |
|
346 | tip-node: bae4d45c759e30f1cb1a40e1382cf0e0414154db | |
|
347 | data-length: 123584 (pure !) | |
|
348 | data-length: 123584 (rust !) | |
|
349 | data-length: 123136 (no-pure no-rust !) | |
|
350 | data-unused: 448 (pure !) | |
|
351 | data-unused: 448 (rust !) | |
|
352 | data-unused: 0 (no-pure no-rust !) | |
|
353 | ||
|
354 | $ cat output.txt | |
|
355 |
General Comments 0
You need to be logged in to leave comments.
Login now