Debian Codegraph @

tests/test-tags.t

raw
1 setup
2
3 $ cat >> $HGRCPATH << EOF
4 > [extensions]
5 > blackbox=
6 > mock=$TESTDIR/mockblackbox.py
7 > [blackbox]
8 > track = command, commandfinish, tagscache
9 > EOF
10
11 Helper functions:
12
13 $ cacheexists() {
14 > [ -f .hg/cache/tags2-visible ] && echo "tag cache exists" || echo "no tag cache"
15 > }
16
17 $ fnodescacheexists() {
18 > [ -f .hg/cache/hgtagsfnodes1 ] && echo "fnodes cache exists" || echo "no fnodes cache"
19 > }
20
21 $ dumptags() {
22 > rev=$1
23 > echo "rev $rev: .hgtags:"
24 > hg cat -r$rev .hgtags
25 > }
26
27 # XXX need to test that the tag cache works when we strip an old head
28 # and add a new one rooted off non-tip: i.e. node and rev of tip are the
29 # same, but stuff has changed behind tip.
30
31 Setup:
32
33 $ hg init t
34 $ cd t
35 $ cacheexists
36 no tag cache
37 $ fnodescacheexists
38 no fnodes cache
39 $ hg id
40 000000000000 tip
41 $ cacheexists
42 no tag cache
43 $ fnodescacheexists
44 no fnodes cache
45 $ echo a > a
46 $ hg add a
47 $ hg commit -m "test"
48 $ hg co
49 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
50 $ hg identify
51 acb14030fe0a tip
52 $ hg identify -r 'wdir()'
53 acb14030fe0a tip
54 $ cacheexists
55 tag cache exists
56 No fnodes cache because .hgtags file doesn't exist
57 (this is an implementation detail)
58 $ fnodescacheexists
59 no fnodes cache
60
61 Try corrupting the cache
62
63 $ printf 'a b' > .hg/cache/tags2-visible
64 $ hg identify
65 acb14030fe0a tip
66 $ cacheexists
67 tag cache exists
68 $ fnodescacheexists
69 no fnodes cache
70 $ hg identify
71 acb14030fe0a tip
72
73 Create local tag with long name:
74
75 $ T=`hg identify -r . -T '{node}'`
76 $ hg tag -l "This is a local tag with a really long name!"
77 $ hg tags
78 tip 0:acb14030fe0a
79 This is a local tag with a really long name! 0:acb14030fe0a
80 $ rm .hg/localtags
81
82 Create a tag behind hg's back:
83
84 $ echo "$T first" > .hgtags
85 $ cat .hgtags
86 acb14030fe0a21b60322c440ad2d20cf7685a376 first
87 $ hg add .hgtags
88 $ hg commit -m "add tags"
89 $ hg tags
90 tip 1:b9154636be93
91 first 0:acb14030fe0a
92 $ hg identify
93 b9154636be93 tip
94
95 We should have a fnodes cache now that we have a real tag
96 The cache should have an empty entry for rev 0 and a valid entry for rev 1.
97
98
99 $ fnodescacheexists
100 fnodes cache exists
101 $ f --size --hexdump .hg/cache/hgtagsfnodes1
102 .hg/cache/hgtagsfnodes1: size=48
103 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
104 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
105 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
106 $ hg debugtagscache
107 0 acb14030fe0a21b60322c440ad2d20cf7685a376 missing
108 1 b9154636be938d3d431e75a7c906504a079bfe07 26b7b4a773e09ee3c52f510e19e05e1ff966d859
109
110 Repeat with cold tag cache:
111
112 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
113 $ hg identify
114 b9154636be93 tip
115
116 $ fnodescacheexists
117 fnodes cache exists
118 $ f --size --hexdump .hg/cache/hgtagsfnodes1
119 .hg/cache/hgtagsfnodes1: size=48
120 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
121 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
122 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
123
124 And again, but now unable to write tag cache or lock file:
125
126 #if unix-permissions no-fsmonitor
127
128 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
129 $ chmod 555 .hg/cache
130 $ hg identify
131 b9154636be93 tip
132 $ chmod 755 .hg/cache
133
134 (this block should be protected by no-fsmonitor, because "chmod 555 .hg"
135 makes watchman fail at accessing to files under .hg)
136
137 $ chmod 555 .hg
138 $ hg identify
139 b9154636be93 tip
140 $ chmod 755 .hg
141 #endif
142
143 Tag cache debug info written to blackbox log
144
145 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
146 $ hg identify
147 b9154636be93 tip
148 $ hg blackbox -l 6
149 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify
150 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing 48 bytes to cache/hgtagsfnodes1
151 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/2 cache hits/lookups in * seconds (glob)
152 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
153 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify exited 0 after * seconds (glob)
154 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
155
156 Failure to acquire lock results in no write
157
158 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
159 $ echo 'foo:1' > .hg/store/lock
160 $ hg identify
161 b9154636be93 tip
162 $ hg blackbox -l 6
163 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify
164 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> not writing .hg/cache/hgtagsfnodes1 because lock cannot be acquired
165 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/2 cache hits/lookups in * seconds (glob)
166 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
167 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify exited 0 after * seconds (glob)
168 1970-01-01 00:00:00.000 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
169
170 $ fnodescacheexists
171 no fnodes cache
172
173 $ rm .hg/store/lock
174
175 $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
176 $ hg identify
177 b9154636be93 tip
178
179 Create a branch:
180
181 $ echo bb > a
182 $ hg status
183 M a
184 $ hg identify
185 b9154636be93+ tip
186 $ hg co first
187 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
188 $ hg id
189 acb14030fe0a+ first
190 $ hg id -r 'wdir()'
191 acb14030fe0a+ first
192 $ hg -v id
193 acb14030fe0a+ first
194 $ hg status
195 M a
196 $ echo 1 > b
197 $ hg add b
198 $ hg commit -m "branch"
199 created new head
200
201 Creating a new commit shouldn't append the .hgtags fnodes cache until
202 tags info is accessed
203
204 $ f --size --hexdump .hg/cache/hgtagsfnodes1
205 .hg/cache/hgtagsfnodes1: size=48
206 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
207 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
208 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
209
210 $ hg id
211 c8edf04160c7 tip
212
213 First 4 bytes of record 3 are changeset fragment
214
215 $ f --size --hexdump .hg/cache/hgtagsfnodes1
216 .hg/cache/hgtagsfnodes1: size=72
217 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
218 0010: ff ff ff ff ff ff ff ff b9 15 46 36 26 b7 b4 a7 |..........F6&...|
219 0020: 73 e0 9e e3 c5 2f 51 0e 19 e0 5e 1f f9 66 d8 59 |s..../Q...^..f.Y|
220 0030: c8 ed f0 41 00 00 00 00 00 00 00 00 00 00 00 00 |...A............|
221 0040: 00 00 00 00 00 00 00 00 |........|
222
223 Merge the two heads:
224
225 $ hg merge 1
226 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
227 (branch merge, don't forget to commit)
228 $ hg blackbox -l3
229 1970-01-01 00:00:00.000 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28 (5000)> merge 1
230 1970-01-01 00:00:00.000 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28+b9154636be938d3d431e75a7c906504a079bfe07 (5000)> merge 1 exited 0 after * seconds (glob)
231 1970-01-01 00:00:00.000 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28+b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l3
232 $ hg id
233 c8edf04160c7+b9154636be93+ tip
234 $ hg status
235 M .hgtags
236 $ hg commit -m "merge"
237
238 Create a fake head, make sure tag not visible afterwards:
239
240 $ cp .hgtags tags
241 $ hg tag last
242 $ hg rm .hgtags
243 $ hg commit -m "remove"
244
245 $ mv tags .hgtags
246 $ hg add .hgtags
247 $ hg commit -m "readd"
248 $
249 $ hg tags
250 tip 6:35ff301afafe
251 first 0:acb14030fe0a
252
253 Add invalid tags:
254
255 $ echo "spam" >> .hgtags
256 $ echo >> .hgtags
257 $ echo "foo bar" >> .hgtags
258 $ echo "a5a5 invalid" >> .hg/localtags
259 $ cat .hgtags
260 acb14030fe0a21b60322c440ad2d20cf7685a376 first
261 spam
262
263 foo bar
264 $ hg commit -m "tags"
265
266 Report tag parse error on other head:
267
268 $ hg up 3
269 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
270 $ echo 'x y' >> .hgtags
271 $ hg commit -m "head"
272 created new head
273
274 $ hg tags --debug
275 .hgtags@75d9f02dfe28, line 2: cannot parse entry
276 .hgtags@75d9f02dfe28, line 4: node 'foo' is not well formed
277 .hgtags@c4be69a18c11, line 2: node 'x' is not well formed
278 tip 8:c4be69a18c11e8bc3a5fdbb576017c25f7d84663
279 first 0:acb14030fe0a21b60322c440ad2d20cf7685a376
280 $ hg tip
281 changeset: 8:c4be69a18c11
282 tag: tip
283 parent: 3:ac5e980c4dc0
284 user: test
285 date: Thu Jan 01 00:00:00 1970 +0000
286 summary: head
287
288
289 Test tag precedence rules:
290
291 $ cd ..
292 $ hg init t2
293 $ cd t2
294 $ echo foo > foo
295 $ hg add foo
296 $ hg ci -m 'add foo' # rev 0
297 $ hg tag bar # rev 1
298 $ echo >> foo
299 $ hg ci -m 'change foo 1' # rev 2
300 $ hg up -C 1
301 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
302 $ hg tag -r 1 -f bar # rev 3
303 $ hg up -C 1
304 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
305 $ echo >> foo
306 $ hg ci -m 'change foo 2' # rev 4
307 created new head
308 $ hg tags
309 tip 4:0c192d7d5e6b
310 bar 1:78391a272241
311
312 Repeat in case of cache effects:
313
314 $ hg tags
315 tip 4:0c192d7d5e6b
316 bar 1:78391a272241
317
318 Detailed dump of tag info:
319
320 $ hg heads -q # expect 4, 3, 2
321 4:0c192d7d5e6b
322 3:6fa450212aeb
323 2:7a94127795a3
324 $ dumptags 2
325 rev 2: .hgtags:
326 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
327 $ dumptags 3
328 rev 3: .hgtags:
329 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
330 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
331 78391a272241d70354aa14c874552cad6b51bb42 bar
332 $ dumptags 4
333 rev 4: .hgtags:
334 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
335
336 Dump cache:
337
338 $ cat .hg/cache/tags2-visible
339 4 0c192d7d5e6b78a714de54a2e9627952a877e25a
340 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
341 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
342 78391a272241d70354aa14c874552cad6b51bb42 bar
343
344 $ f --size --hexdump .hg/cache/hgtagsfnodes1
345 .hg/cache/hgtagsfnodes1: size=120
346 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
347 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
348 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
349 0030: 7a 94 12 77 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |z..w.....1....B(|
350 0040: 78 ee 5a 2d ad bc 94 3d 6f a4 50 21 7d 3b 71 8c |x.Z-...=o.P!};q.|
351 0050: 96 4e f3 7b 89 e5 50 eb da fd 57 89 e7 6c e1 b0 |.N.{..P...W..l..|
352 0060: 0c 19 2d 7d 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |..-}.....1....B(|
353 0070: 78 ee 5a 2d ad bc 94 3d |x.Z-...=|
354
355 Corrupt the .hgtags fnodes cache
356 Extra junk data at the end should get overwritten on next cache update
357
358 $ echo extra >> .hg/cache/hgtagsfnodes1
359 $ echo dummy1 > foo
360 $ hg commit -m throwaway1
361
362 $ hg tags
363 tip 5:8dbfe60eff30
364 bar 1:78391a272241
365
366 $ hg blackbox -l 6
367 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> tags
368 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing 24 bytes to cache/hgtagsfnodes1
369 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> 3/4 cache hits/lookups in * seconds (glob)
370 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing .hg/cache/tags2-visible with 1 tags
371 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> tags exited 0 after * seconds (glob)
372 1970-01-01 00:00:00.000 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> blackbox -l 6
373
374 On junk data + missing cache entries, hg also overwrites the junk.
375
376 $ rm -f .hg/cache/tags2-visible
377 >>> import os
378 >>> with open(".hg/cache/hgtagsfnodes1", "ab+") as fp:
379 ... fp.seek(-10, os.SEEK_END) and None
380 ... fp.truncate() and None
381
382 $ hg debugtagscache | tail -2
383 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
384 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 missing
385 $ hg tags
386 tip 5:8dbfe60eff30
387 bar 1:78391a272241
388 $ hg debugtagscache | tail -2
389 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
390 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8af31de17fab7422878ee5a2dadbc943d
391
392 If the 4 bytes of node hash for a record don't match an existing node, the entry
393 is flagged as invalid.
394
395 >>> import os
396 >>> with open(".hg/cache/hgtagsfnodes1", "rb+") as fp:
397 ... fp.seek(-24, os.SEEK_END) and None
398 ... fp.write(b'\xde\xad') and None
399
400 $ f --size --hexdump .hg/cache/hgtagsfnodes1
401 .hg/cache/hgtagsfnodes1: size=144
402 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
403 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
404 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
405 0030: 7a 94 12 77 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |z..w.....1....B(|
406 0040: 78 ee 5a 2d ad bc 94 3d 6f a4 50 21 7d 3b 71 8c |x.Z-...=o.P!};q.|
407 0050: 96 4e f3 7b 89 e5 50 eb da fd 57 89 e7 6c e1 b0 |.N.{..P...W..l..|
408 0060: 0c 19 2d 7d 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |..-}.....1....B(|
409 0070: 78 ee 5a 2d ad bc 94 3d de ad e6 0e 0c 04 f2 a8 |x.Z-...=........|
410 0080: af 31 de 17 fa b7 42 28 78 ee 5a 2d ad bc 94 3d |.1....B(x.Z-...=|
411
412 $ hg debugtagscache | tail -2
413 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
414 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 invalid
415
416 $ hg tags
417 tip 5:8dbfe60eff30
418 bar 1:78391a272241
419
420 BUG: If the filenode part of an entry in hgtagsfnodes is corrupt and
421 tags2-visible is missing, `hg tags` aborts. Corrupting the leading 4 bytes of
422 node hash (as above) doesn't seem to trigger the issue. Also note that the
423 debug command hides the corruption, both with and without tags2-visible.
424
425 $ mv .hg/cache/hgtagsfnodes1 .hg/cache/hgtagsfnodes1.bak
426 $ hg debugupdatecaches
427
428 >>> import os
429 >>> with open(".hg/cache/hgtagsfnodes1", "rb+") as fp:
430 ... fp.seek(-16, os.SEEK_END) and None
431 ... fp.write(b'\xde\xad') and None
432
433 $ f --size --hexdump .hg/cache/hgtagsfnodes1
434 .hg/cache/hgtagsfnodes1: size=144
435 0000: bb d1 79 df 00 00 00 00 00 00 00 00 00 00 00 00 |..y.............|
436 0010: 00 00 00 00 00 00 00 00 78 39 1a 27 0c 04 f2 a8 |........x9.'....|
437 0020: af 31 de 17 fa b7 42 28 78 ee 5a 2d ad bc 94 3d |.1....B(x.Z-...=|
438 0030: 7a 94 12 77 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |z..w.....1....B(|
439 0040: 78 ee 5a 2d ad bc 94 3d 6f a4 50 21 7d 3b 71 8c |x.Z-...=o.P!};q.|
440 0050: 96 4e f3 7b 89 e5 50 eb da fd 57 89 e7 6c e1 b0 |.N.{..P...W..l..|
441 0060: 0c 19 2d 7d 0c 04 f2 a8 af 31 de 17 fa b7 42 28 |..-}.....1....B(|
442 0070: 78 ee 5a 2d ad bc 94 3d 8d bf e6 0e 0c 04 f2 a8 |x.Z-...=........|
443 0080: de ad de 17 fa b7 42 28 78 ee 5a 2d ad bc 94 3d |......B(x.Z-...=|
444
445 $ hg debugtagscache | tail -2
446 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
447 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d (unknown node)
448
449 $ rm -f .hg/cache/tags2-visible
450 $ hg debugtagscache | tail -2
451 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
452 5 8dbfe60eff306a54259cfe007db9e330e7ecf866 0c04f2a8deadde17fab7422878ee5a2dadbc943d (unknown node)
453
454 $ hg tags
455 tip 5:8dbfe60eff30
456 bar 1:78391a272241
457
458 BUG: Unless this file is restored, the `hg tags` in the next unix-permissions
459 conditional will fail: "abort: data/.hgtags.i@0c04f2a8dead: no match found"
460
461 $ mv .hg/cache/hgtagsfnodes1.bak .hg/cache/hgtagsfnodes1
462
463 #if unix-permissions no-root
464 Errors writing to .hgtags fnodes cache are silently ignored
465
466 $ echo dummy2 > foo
467 $ hg commit -m throwaway2
468
469 $ chmod a-w .hg/cache/hgtagsfnodes1
470 $ rm -f .hg/cache/tags2-visible
471
472 $ hg tags
473 tip 6:b968051b5cf3
474 bar 1:78391a272241
475
476 $ hg blackbox -l 6
477 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
478 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> couldn't write cache/hgtagsfnodes1: [Errno *] * (glob)
479 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/4 cache hits/lookups in * seconds (glob)
480 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
481 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
482 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
483
484 $ chmod a+w .hg/cache/hgtagsfnodes1
485
486 $ rm -f .hg/cache/tags2-visible
487 $ hg tags
488 tip 6:b968051b5cf3
489 bar 1:78391a272241
490
491 $ hg blackbox -l 6
492 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags
493 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing 24 bytes to cache/hgtagsfnodes1
494 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/4 cache hits/lookups in * seconds (glob)
495 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
496 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
497 1970-01-01 00:00:00.000 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
498
499 $ f --size .hg/cache/hgtagsfnodes1
500 .hg/cache/hgtagsfnodes1: size=168
501
502 $ hg -q --config extensions.strip= strip -r 6 --no-backup
503 #endif
504
505 Stripping doesn't truncate the tags cache until new data is available
506
507 $ rm -f .hg/cache/hgtagsfnodes1 .hg/cache/tags2-visible
508 $ hg tags
509 tip 5:8dbfe60eff30
510 bar 1:78391a272241
511
512 $ f --size .hg/cache/hgtagsfnodes1
513 .hg/cache/hgtagsfnodes1: size=144
514
515 $ hg -q --config extensions.strip= strip -r 5 --no-backup
516 $ hg tags
517 tip 4:0c192d7d5e6b
518 bar 1:78391a272241
519
520 $ hg blackbox -l 5
521 1970-01-01 00:00:00.000 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing 24 bytes to cache/hgtagsfnodes1
522 1970-01-01 00:00:00.000 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> 2/4 cache hits/lookups in * seconds (glob)
523 1970-01-01 00:00:00.000 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing .hg/cache/tags2-visible with 1 tags
524 1970-01-01 00:00:00.000 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> tags exited 0 after * seconds (glob)
525 1970-01-01 00:00:00.000 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> blackbox -l 5
526
527 $ f --size .hg/cache/hgtagsfnodes1
528 .hg/cache/hgtagsfnodes1: size=120
529
530 $ echo dummy > foo
531 $ hg commit -m throwaway3
532
533 $ hg tags
534 tip 5:035f65efb448
535 bar 1:78391a272241
536
537 $ hg blackbox -l 6
538 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> tags
539 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing 24 bytes to cache/hgtagsfnodes1
540 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> 3/4 cache hits/lookups in * seconds (glob)
541 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing .hg/cache/tags2-visible with 1 tags
542 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> tags exited 0 after * seconds (glob)
543 1970-01-01 00:00:00.000 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> blackbox -l 6
544 $ f --size .hg/cache/hgtagsfnodes1
545 .hg/cache/hgtagsfnodes1: size=144
546
547 $ hg -q --config extensions.strip= strip -r 5 --no-backup
548
549 Test tag removal:
550
551 $ hg tag --remove bar # rev 5
552 $ hg tip -vp
553 changeset: 5:5f6e8655b1c7
554 tag: tip
555 user: test
556 date: Thu Jan 01 00:00:00 1970 +0000
557 files: .hgtags
558 description:
559 Removed tag bar
560
561
562 diff -r 0c192d7d5e6b -r 5f6e8655b1c7 .hgtags
563 --- a/.hgtags Thu Jan 01 00:00:00 1970 +0000
564 +++ b/.hgtags Thu Jan 01 00:00:00 1970 +0000
565 @@ -1,1 +1,3 @@
566 bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
567 +78391a272241d70354aa14c874552cad6b51bb42 bar
568 +0000000000000000000000000000000000000000 bar
569
570 $ hg tags
571 tip 5:5f6e8655b1c7
572 $ hg tags # again, try to expose cache bugs
573 tip 5:5f6e8655b1c7
574
575 Remove nonexistent tag:
576
577 $ hg tag --remove foobar
578 abort: tag 'foobar' does not exist
579 [10]
580 $ hg tip
581 changeset: 5:5f6e8655b1c7
582 tag: tip
583 user: test
584 date: Thu Jan 01 00:00:00 1970 +0000
585 summary: Removed tag bar
586
587
588 Undo a tag with rollback:
589
590 $ hg rollback # destroy rev 5 (restore bar)
591 repository tip rolled back to revision 4 (undo commit)
592 working directory now based on revision 4
593 $ hg tags
594 tip 4:0c192d7d5e6b
595 bar 1:78391a272241
596 $ hg tags
597 tip 4:0c192d7d5e6b
598 bar 1:78391a272241
599
600 Test tag rank:
601
602 $ cd ..
603 $ hg init t3
604 $ cd t3
605 $ echo foo > foo
606 $ hg add foo
607 $ hg ci -m 'add foo' # rev 0
608 $ hg tag -f bar # rev 1 bar -> 0
609 $ hg tag -f bar # rev 2 bar -> 1
610 $ hg tag -fr 0 bar # rev 3 bar -> 0
611 $ hg tag -fr 1 bar # rev 4 bar -> 1
612 $ hg tag -fr 0 bar # rev 5 bar -> 0
613 $ hg tags
614 tip 5:85f05169d91d
615 bar 0:bbd179dfa0a7
616 $ hg co 3
617 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
618 $ echo barbar > foo
619 $ hg ci -m 'change foo' # rev 6
620 created new head
621 $ hg tags
622 tip 6:735c3ca72986
623 bar 0:bbd179dfa0a7
624
625 Don't allow moving tag without -f:
626
627 $ hg tag -r 3 bar
628 abort: tag 'bar' already exists (use -f to force)
629 [10]
630 $ hg tags
631 tip 6:735c3ca72986
632 bar 0:bbd179dfa0a7
633
634 Strip 1: expose an old head:
635
636 $ hg --config extensions.mq= strip 5
637 saved backup bundle to $TESTTMP/t3/.hg/strip-backup/*-backup.hg (glob)
638 $ hg tags # partly stale cache
639 tip 5:735c3ca72986
640 bar 1:78391a272241
641 $ hg tags # up-to-date cache
642 tip 5:735c3ca72986
643 bar 1:78391a272241
644
645 Strip 2: destroy whole branch, no old head exposed
646
647 $ hg --config extensions.mq= strip 4
648 saved backup bundle to $TESTTMP/t3/.hg/strip-backup/*-backup.hg (glob)
649 $ hg tags # partly stale
650 tip 4:735c3ca72986
651 bar 0:bbd179dfa0a7
652 $ rm -f .hg/cache/tags2-visible
653 $ hg tags # cold cache
654 tip 4:735c3ca72986
655 bar 0:bbd179dfa0a7
656
657 Test tag rank with 3 heads:
658
659 $ cd ..
660 $ hg init t4
661 $ cd t4
662 $ echo foo > foo
663 $ hg add
664 adding foo
665 $ hg ci -m 'add foo' # rev 0
666 $ hg tag bar # rev 1 bar -> 0
667 $ hg tag -f bar # rev 2 bar -> 1
668 $ hg up -qC 0
669 $ hg tag -fr 2 bar # rev 3 bar -> 2
670 $ hg tags
671 tip 3:197c21bbbf2c
672 bar 2:6fa450212aeb
673 $ hg up -qC 0
674 $ hg tag -m 'retag rev 0' -fr 0 bar # rev 4 bar -> 0, but bar stays at 2
675
676 Bar should still point to rev 2:
677
678 $ hg tags
679 tip 4:3b4b14ed0202
680 bar 2:6fa450212aeb
681
682 Test that removing global/local tags does not get confused when trying
683 to remove a tag of type X which actually only exists as a type Y:
684
685 $ cd ..
686 $ hg init t5
687 $ cd t5
688 $ echo foo > foo
689 $ hg add
690 adding foo
691 $ hg ci -m 'add foo' # rev 0
692
693 $ hg tag -r 0 -l localtag
694 $ hg tag --remove localtag
695 abort: tag 'localtag' is not a global tag
696 [10]
697 $
698 $ hg tag -r 0 globaltag
699 $ hg tag --remove -l globaltag
700 abort: tag 'globaltag' is not a local tag
701 [10]
702 $ hg tags -v
703 tip 1:a0b6fe111088
704 localtag 0:bbd179dfa0a7 local
705 globaltag 0:bbd179dfa0a7
706
707 Templated output:
708
709 (immediate values)
710
711 $ hg tags -T '{pad(tag, 9)} {rev}:{node} ({type})\n'
712 tip 1:a0b6fe111088c8c29567d3876cc466aa02927cae ()
713 localtag 0:bbd179dfa0a71671c253b3ae0aa1513b60d199fa (local)
714 globaltag 0:bbd179dfa0a71671c253b3ae0aa1513b60d199fa ()
715
716 (ctx/revcache dependent)
717
718 $ hg tags -T '{pad(tag, 9)} {rev} {file_adds}\n'
719 tip 1 .hgtags
720 localtag 0 foo
721 globaltag 0 foo
722
723 $ hg tags -T '{pad(tag, 9)} {rev}:{node|shortest}\n'
724 tip 1:a0b6
725 localtag 0:bbd1
726 globaltag 0:bbd1
727
728 Test for issue3911
729
730 $ hg tag -r 0 -l localtag2
731 $ hg tag -l --remove localtag2
732 $ hg tags -v
733 tip 1:a0b6fe111088
734 localtag 0:bbd179dfa0a7 local
735 globaltag 0:bbd179dfa0a7
736
737 $ hg tag -r 1 -f localtag
738 $ hg tags -v
739 tip 2:5c70a037bb37
740 localtag 1:a0b6fe111088
741 globaltag 0:bbd179dfa0a7
742
743 $ hg tags -v
744 tip 2:5c70a037bb37
745 localtag 1:a0b6fe111088
746 globaltag 0:bbd179dfa0a7
747
748 $ hg tag -r 1 localtag2
749 $ hg tags -v
750 tip 3:bbfb8cd42be2
751 localtag2 1:a0b6fe111088
752 localtag 1:a0b6fe111088
753 globaltag 0:bbd179dfa0a7
754
755 $ hg tags -v
756 tip 3:bbfb8cd42be2
757 localtag2 1:a0b6fe111088
758 localtag 1:a0b6fe111088
759 globaltag 0:bbd179dfa0a7
760
761 $ cd ..
762
763 Create a repository with tags data to test .hgtags fnodes transfer
764
765 $ hg init tagsserver
766 $ cd tagsserver
767 $ touch foo
768 $ hg -q commit -A -m initial
769 $ hg tag -m 'tag 0.1' 0.1
770 $ echo second > foo
771 $ hg commit -m second
772 $ hg tag -m 'tag 0.2' 0.2
773 $ hg tags
774 tip 3:40f0358cb314
775 0.2 2:f63cc8fe54e4
776 0.1 0:96ee1d7354c4
777 $ cd ..
778
779 Cloning should pull down hgtags fnodes mappings and write the cache file
780
781 $ hg clone --pull tagsserver tagsclient
782 requesting all changes
783 adding changesets
784 adding manifests
785 adding file changes
786 added 4 changesets with 4 changes to 2 files
787 new changesets 96ee1d7354c4:40f0358cb314
788 updating to branch default
789 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
790
791 Missing tags2* files means the cache wasn't written through the normal mechanism.
792
793 $ ls tagsclient/.hg/cache
794 branch2-base
795 hgtagsfnodes1
796 rbc-names-v2
797 rbc-revs-v2
798 tags2
799 tags2-served
800
801 Cache should contain the head only, even though other nodes have tags data
802
803 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
804 tagsclient/.hg/cache/hgtagsfnodes1: size=96
805 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
806 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
807 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
808 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
809 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |[email protected].....|
810 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
811
812 Running hg tags should produce tags2* file and not change cache
813
814 $ hg -R tagsclient tags
815 tip 3:40f0358cb314
816 0.2 2:f63cc8fe54e4
817 0.1 0:96ee1d7354c4
818
819 $ ls tagsclient/.hg/cache
820 branch2-base
821 hgtagsfnodes1
822 rbc-names-v2
823 rbc-revs-v2
824 tags2
825 tags2-served
826 tags2-visible
827
828 $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1
829 tagsclient/.hg/cache/hgtagsfnodes1: size=96
830 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
831 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
832 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
833 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
834 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |[email protected].....|
835 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.|
836
837 Check that the bundle includes cache data
838
839 $ hg -R tagsclient bundle --all ./test-cache-in-bundle-all-rev.hg
840 4 changesets found
841 $ hg debugbundle ./test-cache-in-bundle-all-rev.hg
842 Stream params: {Compression: BZ}
843 changegroup -- {nbchanges: 4, version: 02} (mandatory: True)
844 96ee1d7354c4ad7372047672c36a1f561e3a6a4c
845 c4dab0c2fd337eb9191f80c3024830a4889a8f34
846 f63cc8fe54e4d326f8d692805d70e092f851ddb1
847 40f0358cb314c824a5929ee527308d90e023bc10
848 hgtagsfnodes -- {} (mandatory: False)
849 cache:rev-branch-cache -- {} (mandatory: False)
850
851 Check that local clone includes cache data
852
853 $ hg clone tagsclient tags-local-clone
854 updating to branch default
855 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
856 $ (cd tags-local-clone/.hg/cache/; ls -1 tag*)
857 tags2
858 tags2-served
859 tags2-visible
860
861 Avoid writing logs on trying to delete an already deleted tag
862 $ hg init issue5752
863 $ cd issue5752
864 $ echo > a
865 $ hg commit -Am 'add a'
866 adding a
867 $ hg tag a
868 $ hg tags
869 tip 1:bd7ee4f3939b
870 a 0:a8a82d372bb3
871 $ hg log
872 changeset: 1:bd7ee4f3939b
873 tag: tip
874 user: test
875 date: Thu Jan 01 00:00:00 1970 +0000
876 summary: Added tag a for changeset a8a82d372bb3
877
878 changeset: 0:a8a82d372bb3
879 tag: a
880 user: test
881 date: Thu Jan 01 00:00:00 1970 +0000
882 summary: add a
883
884 $ hg tag --remove a
885 $ hg log
886 changeset: 2:e7feacc7ec9e
887 tag: tip
888 user: test
889 date: Thu Jan 01 00:00:00 1970 +0000
890 summary: Removed tag a
891
892 changeset: 1:bd7ee4f3939b
893 user: test
894 date: Thu Jan 01 00:00:00 1970 +0000
895 summary: Added tag a for changeset a8a82d372bb3
896
897 changeset: 0:a8a82d372bb3
898 user: test
899 date: Thu Jan 01 00:00:00 1970 +0000
900 summary: add a
901
902 $ hg tag --remove a
903 abort: tag 'a' is already removed
904 [10]
905 $ hg log
906 changeset: 2:e7feacc7ec9e
907 tag: tip
908 user: test
909 date: Thu Jan 01 00:00:00 1970 +0000
910 summary: Removed tag a
911
912 changeset: 1:bd7ee4f3939b
913 user: test
914 date: Thu Jan 01 00:00:00 1970 +0000
915 summary: Added tag a for changeset a8a82d372bb3
916
917 changeset: 0:a8a82d372bb3
918 user: test
919 date: Thu Jan 01 00:00:00 1970 +0000
920 summary: add a
921
922 $ cat .hgtags
923 a8a82d372bb35b42ff736e74f07c23bcd99c371f a
924 a8a82d372bb35b42ff736e74f07c23bcd99c371f a
925 0000000000000000000000000000000000000000 a
926
927 $ cd ..
928
929 .hgtags fnode should be properly resolved at merge revision (issue6673)
930
931 $ hg init issue6673
932 $ cd issue6673
933
934 $ touch a
935 $ hg ci -qAm a
936 $ hg branch -q stable
937 $ hg ci -m branch
938
939 $ hg up -q default
940 $ hg merge -q stable
941 $ hg ci -m merge
942
943 add tag to stable branch:
944
945 $ hg up -q stable
946 $ echo a >> a
947 $ hg ci -m a
948 $ hg tag whatever
949 $ hg log -GT'{rev} {tags}\n'
950 @ 4 tip
951 |
952 o 3 whatever
953 |
954 | o 2
955 |/|
956 o | 1
957 |/
958 o 0
959
960
961 merge tagged stable into default:
962
963 $ hg up -q default
964 $ hg merge -q stable
965 $ hg ci -m merge
966 $ hg log -GT'{rev} {tags}\n'
967 @ 5 tip
968 |\
969 | o 4
970 | |
971 | o 3 whatever
972 | |
973 o | 2
974 |\|
975 | o 1
976 |/
977 o 0
978
979
980 $ cd ..