Mercurial > hg-stable
comparison tests/test-tag.t @ 31994:b36318e6d2ef
track-tags: introduce first bits of tags tracking during transaction
This changeset introduces detection of tags changes during transaction. When
this happens a 'tag_moved=1' argument is set for hooks, similar to what we do
for bookmarks and phases.
This code is disabled by default as there are still various performance
concerns. Some require a smarter use of our existing tag caches and some other
require rework around the transaction logic to skip execution when unneeded.
These performance improvements have been delayed, I would like to be able to
experiment and stabilize the feature behavior first.
Later changesets will push the concept further and provide a way for hooks to
know what are the actual changes introduced by the transaction. Similar work
is needed for the other families of changes (bookmark, phase, obsolescence,
etc). Upgrade of the transaction logic will likely be performed at the same
time.
The current code can report some false positive when .hgtags file changes but
resulting tags are unchanged. This will be fixed in the next changeset.
For testing, we simply globally enable a hook in the tag test as all the
possible tag update cases should exist there. A couple of them show the false
positive mentioned above.
See in code documentation for more details.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 28 Mar 2017 06:38:09 +0200 |
parents | 27addd7e8eca |
children | fe9c4d614600 |
comparison
equal
deleted
inserted
replaced
31993:bfb826c350d4 | 31994:b36318e6d2ef |
---|---|
1 $ cat >> $HGRCPATH << EOF | |
2 > [experimental] | |
3 > hook-track-tags=1 | |
4 > [hooks] | |
5 > txnclose.track-tag=${TESTTMP}/taghook.sh | |
6 > EOF | |
7 | |
8 $ cat << EOF > taghook.sh | |
9 > #!/bin/sh | |
10 > # escape the "$" otherwise the test runner interpret it when writting the | |
11 > # file... | |
12 > if [ -n "\$HG_TAG_MOVED" ]; then | |
13 > echo 'hook: tag changes detected' | |
14 > fi | |
15 > EOF | |
16 $ chmod +x taghook.sh | |
1 $ hg init test | 17 $ hg init test |
2 $ cd test | 18 $ cd test |
3 | 19 |
4 $ echo a > a | 20 $ echo a > a |
5 $ hg add a | 21 $ hg add a |
18 | 34 |
19 (this tests also that editor is not invoked, if '--edit' is not | 35 (this tests also that editor is not invoked, if '--edit' is not |
20 specified) | 36 specified) |
21 | 37 |
22 $ HGEDITOR=cat hg tag "bleah" | 38 $ HGEDITOR=cat hg tag "bleah" |
39 hook: tag changes detected | |
23 $ hg history | 40 $ hg history |
24 changeset: 1:d4f0d2909abc | 41 changeset: 1:d4f0d2909abc |
25 tag: tip | 42 tag: tip |
26 user: test | 43 user: test |
27 date: Thu Jan 01 00:00:00 1970 +0000 | 44 date: Thu Jan 01 00:00:00 1970 +0000 |
66 $ hg tag --remove "bleah" "blecch" "blough" | 83 $ hg tag --remove "bleah" "blecch" "blough" |
67 abort: tag 'blecch' does not exist | 84 abort: tag 'blecch' does not exist |
68 [255] | 85 [255] |
69 | 86 |
70 $ hg tag -r 0 "bleah0" | 87 $ hg tag -r 0 "bleah0" |
88 hook: tag changes detected | |
71 $ hg tag -l -r 1 "bleah1" | 89 $ hg tag -l -r 1 "bleah1" |
72 $ hg tag gack gawk gorp | 90 $ hg tag gack gawk gorp |
91 hook: tag changes detected | |
73 $ hg tag -f gack | 92 $ hg tag -f gack |
93 hook: tag changes detected | |
74 $ hg tag --remove gack gorp | 94 $ hg tag --remove gack gorp |
95 hook: tag changes detected | |
75 | 96 |
76 $ hg tag "bleah " | 97 $ hg tag "bleah " |
77 abort: tag 'bleah' already exists (use -f to force) | 98 abort: tag 'bleah' already exists (use -f to force) |
78 [255] | 99 [255] |
79 $ hg tag " bleah" | 100 $ hg tag " bleah" |
81 [255] | 102 [255] |
82 $ hg tag " bleah" | 103 $ hg tag " bleah" |
83 abort: tag 'bleah' already exists (use -f to force) | 104 abort: tag 'bleah' already exists (use -f to force) |
84 [255] | 105 [255] |
85 $ hg tag -r 0 " bleahbleah " | 106 $ hg tag -r 0 " bleahbleah " |
107 hook: tag changes detected | |
86 $ hg tag -r 0 " bleah bleah " | 108 $ hg tag -r 0 " bleah bleah " |
109 hook: tag changes detected | |
87 | 110 |
88 $ cat .hgtags | 111 $ cat .hgtags |
89 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah | 112 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah |
90 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0 | 113 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0 |
91 336fccc858a4eb69609a291105009e484a6b6b8d gack | 114 336fccc858a4eb69609a291105009e484a6b6b8d gack |
110 $ hg tag -l localblah | 133 $ hg tag -l localblah |
111 $ hg tag "foobar" | 134 $ hg tag "foobar" |
112 abort: working directory is not at a branch head (use -f to force) | 135 abort: working directory is not at a branch head (use -f to force) |
113 [255] | 136 [255] |
114 $ hg tag -f "foobar" | 137 $ hg tag -f "foobar" |
138 hook: tag changes detected | |
115 $ cat .hgtags | 139 $ cat .hgtags |
116 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | 140 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
117 $ cat .hg/localtags | 141 $ cat .hg/localtags |
118 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 | 142 d4f0d2909abc9290e2773c08837d70c1794e3f5a bleah1 |
119 acb14030fe0a21b60322c440ad2d20cf7685a376 localblah | 143 acb14030fe0a21b60322c440ad2d20cf7685a376 localblah |
167 user: test | 191 user: test |
168 date: Thu Jan 01 00:00:00 1970 +0000 | 192 date: Thu Jan 01 00:00:00 1970 +0000 |
169 summary: Removed tag gack, gorp | 193 summary: Removed tag gack, gorp |
170 | 194 |
171 $ hg clone -q -rbleah1 test test1 | 195 $ hg clone -q -rbleah1 test test1 |
196 hook: tag changes detected | |
172 $ hg -R test1 parents --style=compact | 197 $ hg -R test1 parents --style=compact |
173 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test | 198 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test |
174 Added tag bleah for changeset acb14030fe0a | 199 Added tag bleah for changeset acb14030fe0a |
175 | 200 |
176 $ hg clone -q -r5 test#bleah1 test2 | 201 $ hg clone -q -r5 test#bleah1 test2 |
202 hook: tag changes detected | |
177 $ hg -R test2 parents --style=compact | 203 $ hg -R test2 parents --style=compact |
178 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test | 204 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test |
179 Removed tag gack, gorp | 205 Removed tag gack, gorp |
180 | 206 |
181 $ hg clone -q -U test#bleah1 test3 | 207 $ hg clone -q -U test#bleah1 test3 |
208 hook: tag changes detected | |
182 $ hg -R test3 parents --style=compact | 209 $ hg -R test3 parents --style=compact |
183 | 210 |
184 $ cd test | 211 $ cd test |
185 | 212 |
186 Issue601: hg tag doesn't do the right thing if .hgtags or localtags | 213 Issue601: hg tag doesn't do the right thing if .hgtags or localtags |
201 $ python << EOF | 228 $ python << EOF |
202 > f = file('.hgtags'); last = f.readlines()[-1][:-1]; f.close() | 229 > f = file('.hgtags'); last = f.readlines()[-1][:-1]; f.close() |
203 > f = file('.hgtags', 'w'); f.write(last); f.close() | 230 > f = file('.hgtags', 'w'); f.write(last); f.close() |
204 > EOF | 231 > EOF |
205 $ hg ci -m'broken manual edit of .hgtags' | 232 $ hg ci -m'broken manual edit of .hgtags' |
233 hook: tag changes detected | |
206 $ cat .hgtags; echo | 234 $ cat .hgtags; echo |
207 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | 235 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
208 $ hg tag newline | 236 $ hg tag newline |
237 hook: tag changes detected | |
209 $ cat .hgtags; echo | 238 $ cat .hgtags; echo |
210 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar | 239 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
211 a0eea09de1eeec777b46f2085260a373b2fbc293 newline | 240 a0eea09de1eeec777b46f2085260a373b2fbc293 newline |
212 | 241 |
213 | 242 |
217 marked working directory as branch tag-and-branch-same-name | 246 marked working directory as branch tag-and-branch-same-name |
218 (branches are permanent and global, did you want a bookmark?) | 247 (branches are permanent and global, did you want a bookmark?) |
219 $ hg ci -m"discouraged" | 248 $ hg ci -m"discouraged" |
220 $ hg tag tag-and-branch-same-name | 249 $ hg tag tag-and-branch-same-name |
221 warning: tag tag-and-branch-same-name conflicts with existing branch name | 250 warning: tag tag-and-branch-same-name conflicts with existing branch name |
251 hook: tag changes detected | |
222 | 252 |
223 test custom commit messages | 253 test custom commit messages |
224 | 254 |
225 $ cat > editor.sh << '__EOF__' | 255 $ cat > editor.sh << '__EOF__' |
226 > echo "==== before editing" | 256 > echo "==== before editing" |
301 HG: -- | 331 HG: -- |
302 HG: user: test | 332 HG: user: test |
303 HG: branch 'tag-and-branch-same-name' | 333 HG: branch 'tag-and-branch-same-name' |
304 HG: changed .hgtags | 334 HG: changed .hgtags |
305 ==== | 335 ==== |
336 hook: tag changes detected | |
306 $ hg log -l1 --template "{desc}\n" | 337 $ hg log -l1 --template "{desc}\n" |
307 custom tag message | 338 custom tag message |
308 second line | 339 second line |
309 | 340 |
310 | 341 |
311 local tag with .hgtags modified | 342 local tag with .hgtags modified |
312 | 343 |
313 $ hg tag hgtags-modified | 344 $ hg tag hgtags-modified |
345 hook: tag changes detected | |
314 $ hg rollback | 346 $ hg rollback |
315 repository tip rolled back to revision 13 (undo commit) | 347 repository tip rolled back to revision 13 (undo commit) |
316 working directory now based on revision 13 | 348 working directory now based on revision 13 |
317 $ hg st | 349 $ hg st |
318 M .hgtags | 350 M .hgtags |
328 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 360 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
329 $ hg merge -t internal:local | 361 $ hg merge -t internal:local |
330 0 files updated, 1 files merged, 0 files removed, 0 files unresolved | 362 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
331 (branch merge, don't forget to commit) | 363 (branch merge, don't forget to commit) |
332 $ hg ci -m 'merge named branch' | 364 $ hg ci -m 'merge named branch' |
365 hook: tag changes detected | |
333 $ hg up 13 | 366 $ hg up 13 |
334 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 367 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
335 $ hg tag new-topo-head | 368 $ hg tag new-topo-head |
369 hook: tag changes detected | |
336 | 370 |
337 tagging on null rev | 371 tagging on null rev |
338 | 372 |
339 $ hg up null | 373 $ hg up null |
340 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | 374 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
397 $ hg init repo-tag-target | 431 $ hg init repo-tag-target |
398 $ cat > "$TESTTMP/issue3344.sh" <<EOF | 432 $ cat > "$TESTTMP/issue3344.sh" <<EOF |
399 > hg push "$TESTTMP/repo-tag-target" | 433 > hg push "$TESTTMP/repo-tag-target" |
400 > EOF | 434 > EOF |
401 $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag | 435 $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag |
436 hook: tag changes detected | |
402 pushing to $TESTTMP/repo-tag-target (glob) | 437 pushing to $TESTTMP/repo-tag-target (glob) |
403 searching for changes | 438 searching for changes |
404 adding changesets | 439 adding changesets |
405 adding manifests | 440 adding manifests |
406 adding file changes | 441 adding file changes |
407 added 2 changesets with 2 changes to 2 files | 442 added 2 changesets with 2 changes to 2 files |
443 hook: tag changes detected | |
408 | 444 |
409 automatically merge resolvable tag conflicts (i.e. tags that differ in rank) | 445 automatically merge resolvable tag conflicts (i.e. tags that differ in rank) |
410 create two clones with some different tags as well as some common tags | 446 create two clones with some different tags as well as some common tags |
411 check that we can merge tags that differ in rank | 447 check that we can merge tags that differ in rank |
412 | 448 |
414 $ cd repo-automatic-tag-merge | 450 $ cd repo-automatic-tag-merge |
415 $ echo c0 > f0 | 451 $ echo c0 > f0 |
416 $ hg ci -A -m0 | 452 $ hg ci -A -m0 |
417 adding f0 | 453 adding f0 |
418 $ hg tag tbase | 454 $ hg tag tbase |
455 hook: tag changes detected | |
419 $ hg up -qr '.^' | 456 $ hg up -qr '.^' |
420 $ hg log -r 'wdir()' -T "{latesttagdistance}\n" | 457 $ hg log -r 'wdir()' -T "{latesttagdistance}\n" |
421 1 | 458 1 |
422 $ hg up -q | 459 $ hg up -q |
423 $ hg log -r 'wdir()' -T "{latesttagdistance}\n" | 460 $ hg log -r 'wdir()' -T "{latesttagdistance}\n" |
429 $ cd repo-automatic-tag-merge-clone | 466 $ cd repo-automatic-tag-merge-clone |
430 $ echo c1 > f1 | 467 $ echo c1 > f1 |
431 $ hg ci -A -m1 | 468 $ hg ci -A -m1 |
432 adding f1 | 469 adding f1 |
433 $ hg tag t1 t2 t3 | 470 $ hg tag t1 t2 t3 |
471 hook: tag changes detected | |
434 $ hg tag --remove t2 | 472 $ hg tag --remove t2 |
473 hook: tag changes detected | |
435 $ hg tag t5 | 474 $ hg tag t5 |
475 hook: tag changes detected | |
436 $ echo c2 > f2 | 476 $ echo c2 > f2 |
437 $ hg ci -A -m2 | 477 $ hg ci -A -m2 |
438 adding f2 | 478 adding f2 |
439 $ hg tag -f t3 | 479 $ hg tag -f t3 |
480 hook: tag changes detected | |
440 | 481 |
441 $ cd ../repo-automatic-tag-merge | 482 $ cd ../repo-automatic-tag-merge |
442 $ echo c3 > f3 | 483 $ echo c3 > f3 |
443 $ hg ci -A -m3 | 484 $ hg ci -A -m3 |
444 adding f3 | 485 adding f3 |
445 $ hg tag -f t4 t5 t6 | 486 $ hg tag -f t4 t5 t6 |
487 hook: tag changes detected | |
446 | 488 |
447 $ hg up -q '.^' | 489 $ hg up -q '.^' |
448 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" | 490 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" |
449 1 changes since t4:t5:t6 | 491 1 changes since t4:t5:t6 |
450 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n" | 492 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n" |
453 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" | 495 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" |
454 1 changes since t4:t5:t6 | 496 1 changes since t4:t5:t6 |
455 $ hg up -qC | 497 $ hg up -qC |
456 | 498 |
457 $ hg tag --remove t5 | 499 $ hg tag --remove t5 |
500 hook: tag changes detected | |
458 $ echo c4 > f4 | 501 $ echo c4 > f4 |
459 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n" | 502 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n" |
460 2 changes since t4:t6 | 503 2 changes since t4:t6 |
461 $ hg log -r '.' -T "{latesttag % '{latesttag}\n'}" | 504 $ hg log -r '.' -T "{latesttag % '{latesttag}\n'}" |
462 t4 | 505 t4 |
471 $ hg ci -A -m4 | 514 $ hg ci -A -m4 |
472 adding f4 | 515 adding f4 |
473 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" | 516 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" |
474 4 changes since t4:t6 | 517 4 changes since t4:t6 |
475 $ hg tag t2 | 518 $ hg tag t2 |
519 hook: tag changes detected | |
476 $ hg tag -f t6 | 520 $ hg tag -f t6 |
521 hook: tag changes detected | |
477 | 522 |
478 $ cd ../repo-automatic-tag-merge-clone | 523 $ cd ../repo-automatic-tag-merge-clone |
479 $ hg pull | 524 $ hg pull |
480 pulling from $TESTTMP/repo-automatic-tag-merge (glob) | 525 pulling from $TESTTMP/repo-automatic-tag-merge (glob) |
481 searching for changes | 526 searching for changes |
482 adding changesets | 527 adding changesets |
483 adding manifests | 528 adding manifests |
484 adding file changes | 529 adding file changes |
485 added 6 changesets with 6 changes to 3 files (+1 heads) | 530 added 6 changesets with 6 changes to 3 files (+1 heads) |
531 hook: tag changes detected | |
486 (run 'hg heads' to see heads, 'hg merge' to merge) | 532 (run 'hg heads' to see heads, 'hg merge' to merge) |
487 $ hg merge --tool internal:tagmerge | 533 $ hg merge --tool internal:tagmerge |
488 merging .hgtags | 534 merging .hgtags |
489 2 files updated, 1 files merged, 0 files removed, 0 files unresolved | 535 2 files updated, 1 files merged, 0 files removed, 0 files unresolved |
490 (branch merge, don't forget to commit) | 536 (branch merge, don't forget to commit) |
541 detect merge tag conflicts | 587 detect merge tag conflicts |
542 | 588 |
543 $ hg update -C -r tip | 589 $ hg update -C -r tip |
544 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | 590 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
545 $ hg tag t7 | 591 $ hg tag t7 |
592 hook: tag changes detected | |
546 $ hg update -C -r 'first(sort(head()))' | 593 $ hg update -C -r 'first(sort(head()))' |
547 3 files updated, 0 files merged, 2 files removed, 0 files unresolved | 594 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
548 $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags | 595 $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags |
549 $ hg commit -m "manually add conflicting t7 tag" | 596 $ hg commit -m "manually add conflicting t7 tag" |
597 hook: tag changes detected | |
550 $ hg merge --tool internal:tagmerge | 598 $ hg merge --tool internal:tagmerge |
551 merging .hgtags | 599 merging .hgtags |
552 automatic .hgtags merge failed | 600 automatic .hgtags merge failed |
553 the following 1 tags are in conflict: t7 | 601 the following 1 tags are in conflict: t7 |
554 automatic tag merging of .hgtags failed! (use 'hg resolve --tool :merge' or another merge tool of your choice) | 602 automatic tag merging of .hgtags failed! (use 'hg resolve --tool :merge' or another merge tool of your choice) |
579 $ cd repo-merge-lost-tags | 627 $ cd repo-merge-lost-tags |
580 $ echo c5 > f5 | 628 $ echo c5 > f5 |
581 $ hg ci -A -m5 | 629 $ hg ci -A -m5 |
582 adding f5 | 630 adding f5 |
583 $ hg tag -f t7 | 631 $ hg tag -f t7 |
632 hook: tag changes detected | |
584 $ hg update -r 'p1(t7)' | 633 $ hg update -r 'p1(t7)' |
585 1 files updated, 0 files merged, 1 files removed, 0 files unresolved | 634 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
586 $ printf '' > .hgtags | 635 $ printf '' > .hgtags |
587 $ hg commit -m 'delete all tags' | 636 $ hg commit -m 'delete all tags' |
588 created new head | 637 created new head |
638 hook: tag changes detected | |
589 $ hg log -r 'max(t7::)' | 639 $ hg log -r 'max(t7::)' |
590 changeset: 17:ffe462b50880 | 640 changeset: 17:ffe462b50880 |
591 user: test | 641 user: test |
592 date: Thu Jan 01 00:00:00 1970 +0000 | 642 date: Thu Jan 01 00:00:00 1970 +0000 |
593 summary: Added tag t7 for changeset fd3a9e394ce3 | 643 summary: Added tag t7 for changeset fd3a9e394ce3 |