Show More
@@ -1001,8 +1001,54 b' class localrepository(object):' | |||
|
1001 | 1001 | vfsmap = {'plain': self.vfs} # root of .hg/ |
|
1002 | 1002 | # we must avoid cyclic reference between repo and transaction. |
|
1003 | 1003 | reporef = weakref.ref(self) |
|
1004 | def validate(tr): | |
|
1004 | # Code to track tag movement | |
|
1005 | # | |
|
1006 | # Since tags are all handled as file content, it is actually quite hard | |
|
1007 | # to track these movement from a code perspective. So we fallback to a | |
|
1008 | # tracking at the repository level. One could envision to track changes | |
|
1009 | # to the '.hgtags' file through changegroup apply but that fails to | |
|
1010 | # cope with case where transaction expose new heads without changegroup | |
|
1011 | # being involved (eg: phase movement). | |
|
1012 | # | |
|
1013 | # For now, We gate the feature behind a flag since this likely comes | |
|
1014 | # with performance impacts. The current code run more often than needed | |
|
1015 | # and do not use caches as much as it could. The current focus is on | |
|
1016 | # the behavior of the feature so we disable it by default. The flag | |
|
1017 | # will be removed when we are happy with the performance impact. | |
|
1018 | tracktags = lambda x: None | |
|
1019 | # experimental config: experimental.hook-track-tags | |
|
1020 | shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags', | |
|
1021 | False) | |
|
1022 | if desc != 'strip' and shouldtracktags: | |
|
1023 | oldheads = self.changelog.headrevs() | |
|
1024 | def tracktags(tr2): | |
|
1025 | repo = reporef() | |
|
1026 | oldfnodes = tagsmod.fnoderevs(repo.ui, repo, oldheads) | |
|
1027 | newheads = repo.changelog.headrevs() | |
|
1028 | newfnodes = tagsmod.fnoderevs(repo.ui, repo, newheads) | |
|
1029 | # notes: we compare lists here. | |
|
1030 | # As we do it only once buiding set would not be cheaper | |
|
1031 | if oldfnodes != newfnodes: | |
|
1032 | tr2.hookargs['tag_moved'] = '1' | |
|
1033 | def validate(tr2): | |
|
1005 | 1034 | """will run pre-closing hooks""" |
|
1035 | # XXX the transaction API is a bit lacking here so we take a hacky | |
|
1036 | # path for now | |
|
1037 | # | |
|
1038 | # We cannot add this as a "pending" hooks since the 'tr.hookargs' | |
|
1039 | # dict is copied before these run. In addition we needs the data | |
|
1040 | # available to in memory hooks too. | |
|
1041 | # | |
|
1042 | # Moreover, we also need to make sure this runs before txnclose | |
|
1043 | # hooks and there is no "pending" mechanism that would execute | |
|
1044 | # logic only if hooks are about to run. | |
|
1045 | # | |
|
1046 | # Fixing this limitation of the transaction is also needed to track | |
|
1047 | # other families of changes (bookmarks, phases, obsolescence). | |
|
1048 | # | |
|
1049 | # This will have to be fixed before we remove the experimental | |
|
1050 | # gating. | |
|
1051 | tracktags(tr2) | |
|
1006 | 1052 | reporef().hook('pretxnclose', throw=True, |
|
1007 | 1053 | txnname=desc, **pycompat.strkwargs(tr.hookargs)) |
|
1008 | 1054 | def releasefn(tr, success): |
@@ -1,3 +1,19 b'' | |||
|
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 | 17 |
$ |
|
2 | 18 | $ cd test |
|
3 | 19 | |
@@ -20,6 +36,7 b'' | |||
|
20 | 36 | specified) |
|
21 | 37 | |
|
22 | 38 | $ HGEDITOR=cat hg tag "bleah" |
|
39 | hook: tag changes detected | |
|
23 | 40 |
$ |
|
24 | 41 | changeset: 1:d4f0d2909abc |
|
25 | 42 | tag: tip |
@@ -68,10 +85,14 b' specified)' | |||
|
68 | 85 | [255] |
|
69 | 86 | |
|
70 | 87 | $ hg tag -r 0 "bleah0" |
|
88 | hook: tag changes detected | |
|
71 | 89 |
$ |
|
72 | 90 | $ hg tag gack gawk gorp |
|
91 | hook: tag changes detected | |
|
73 | 92 | $ hg tag -f gack |
|
93 | hook: tag changes detected | |
|
74 | 94 | $ hg tag --remove gack gorp |
|
95 | hook: tag changes detected | |
|
75 | 96 | |
|
76 | 97 | $ hg tag "bleah " |
|
77 | 98 | abort: tag 'bleah' already exists (use -f to force) |
@@ -83,7 +104,9 b' specified)' | |||
|
83 | 104 | abort: tag 'bleah' already exists (use -f to force) |
|
84 | 105 | [255] |
|
85 | 106 | $ hg tag -r 0 " bleahbleah " |
|
107 | hook: tag changes detected | |
|
86 | 108 |
$ |
|
109 | hook: tag changes detected | |
|
87 | 110 | |
|
88 | 111 |
$ |
|
89 | 112 | acb14030fe0a21b60322c440ad2d20cf7685a376 bleah |
@@ -112,6 +135,7 b' tagging on a non-head revision' | |||
|
112 | 135 | abort: working directory is not at a branch head (use -f to force) |
|
113 | 136 | [255] |
|
114 | 137 | $ hg tag -f "foobar" |
|
138 | hook: tag changes detected | |
|
115 | 139 |
$ |
|
116 | 140 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
117 | 141 | $ cat .hg/localtags |
@@ -169,16 +193,19 b' cloning local tags' | |||
|
169 | 193 | summary: Removed tag gack, gorp |
|
170 | 194 | |
|
171 | 195 | $ hg clone -q -rbleah1 test test1 |
|
196 | hook: tag changes detected | |
|
172 | 197 | $ hg -R test1 parents --style=compact |
|
173 | 198 | 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test |
|
174 | 199 | Added tag bleah for changeset acb14030fe0a |
|
175 | 200 | |
|
176 | 201 | $ hg clone -q -r5 test#bleah1 test2 |
|
202 | hook: tag changes detected | |
|
177 | 203 | $ hg -R test2 parents --style=compact |
|
178 | 204 | 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test |
|
179 | 205 | Removed tag gack, gorp |
|
180 | 206 | |
|
181 | 207 | $ hg clone -q -U test#bleah1 test3 |
|
208 | hook: tag changes detected | |
|
182 | 209 | $ hg -R test3 parents --style=compact |
|
183 | 210 | |
|
184 | 211 | $ cd test |
@@ -203,9 +230,11 b" doesn't end with EOL" | |||
|
203 | 230 | > f = file('.hgtags', 'w'); f.write(last); f.close() |
|
204 | 231 | > EOF |
|
205 | 232 | $ hg ci -m'broken manual edit of .hgtags' |
|
233 | hook: tag changes detected | |
|
206 | 234 |
$ |
|
207 | 235 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
208 | 236 | $ hg tag newline |
|
237 | hook: tag changes detected | |
|
209 | 238 |
$ cat .hgtags; |
|
210 | 239 | acb14030fe0a21b60322c440ad2d20cf7685a376 foobar |
|
211 | 240 | a0eea09de1eeec777b46f2085260a373b2fbc293 newline |
@@ -219,6 +248,7 b' tag and branch using same name' | |||
|
219 | 248 | $ hg ci -m"discouraged" |
|
220 | 249 | $ hg tag tag-and-branch-same-name |
|
221 | 250 | warning: tag tag-and-branch-same-name conflicts with existing branch name |
|
251 | hook: tag changes detected | |
|
222 | 252 | |
|
223 | 253 | test custom commit messages |
|
224 | 254 | |
@@ -303,6 +333,7 b' then, test custom commit message itself' | |||
|
303 | 333 | HG: branch 'tag-and-branch-same-name' |
|
304 | 334 | HG: changed .hgtags |
|
305 | 335 | ==== |
|
336 | hook: tag changes detected | |
|
306 | 337 |
$ |
|
307 | 338 | custom tag message |
|
308 | 339 | second line |
@@ -311,6 +342,7 b' then, test custom commit message itself' | |||
|
311 | 342 | local tag with .hgtags modified |
|
312 | 343 | |
|
313 | 344 | $ hg tag hgtags-modified |
|
345 | hook: tag changes detected | |
|
314 | 346 | $ hg rollback |
|
315 | 347 | repository tip rolled back to revision 13 (undo commit) |
|
316 | 348 | working directory now based on revision 13 |
@@ -330,9 +362,11 b" tagging when at named-branch-head that's" | |||
|
330 | 362 | 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
|
331 | 363 | (branch merge, don't forget to commit) |
|
332 | 364 | $ hg ci -m 'merge named branch' |
|
365 | hook: tag changes detected | |
|
333 | 366 | $ hg up 13 |
|
334 | 367 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
335 | 368 | $ hg tag new-topo-head |
|
369 | hook: tag changes detected | |
|
336 | 370 | |
|
337 | 371 | tagging on null rev |
|
338 | 372 | |
@@ -399,12 +433,14 b' commit hook on tag used to be run withou' | |||
|
399 | 433 | > hg push "$TESTTMP/repo-tag-target" |
|
400 | 434 | > EOF |
|
401 | 435 | $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag |
|
436 | hook: tag changes detected | |
|
402 | 437 | pushing to $TESTTMP/repo-tag-target (glob) |
|
403 | 438 | searching for changes |
|
404 | 439 | adding changesets |
|
405 | 440 | adding manifests |
|
406 | 441 | adding file changes |
|
407 | 442 | added 2 changesets with 2 changes to 2 files |
|
443 | hook: tag changes detected | |
|
408 | 444 | |
|
409 | 445 | automatically merge resolvable tag conflicts (i.e. tags that differ in rank) |
|
410 | 446 | create two clones with some different tags as well as some common tags |
@@ -416,6 +452,7 b' check that we can merge tags that differ' | |||
|
416 | 452 | $ hg ci -A -m0 |
|
417 | 453 | adding f0 |
|
418 | 454 | $ hg tag tbase |
|
455 | hook: tag changes detected | |
|
419 | 456 | $ hg up -qr '.^' |
|
420 | 457 | $ hg log -r 'wdir()' -T "{latesttagdistance}\n" |
|
421 | 458 | 1 |
@@ -431,18 +468,23 b' check that we can merge tags that differ' | |||
|
431 | 468 | $ hg ci -A -m1 |
|
432 | 469 | adding f1 |
|
433 | 470 | $ hg tag t1 t2 t3 |
|
471 | hook: tag changes detected | |
|
434 | 472 | $ hg tag --remove t2 |
|
473 | hook: tag changes detected | |
|
435 | 474 | $ hg tag t5 |
|
475 | hook: tag changes detected | |
|
436 | 476 | $ echo c2 > f2 |
|
437 | 477 | $ hg ci -A -m2 |
|
438 | 478 | adding f2 |
|
439 | 479 | $ hg tag -f t3 |
|
480 | hook: tag changes detected | |
|
440 | 481 | |
|
441 | 482 | $ cd ../repo-automatic-tag-merge |
|
442 | 483 | $ echo c3 > f3 |
|
443 | 484 | $ hg ci -A -m3 |
|
444 | 485 | adding f3 |
|
445 | 486 | $ hg tag -f t4 t5 t6 |
|
487 | hook: tag changes detected | |
|
446 | 488 | |
|
447 | 489 | $ hg up -q '.^' |
|
448 | 490 | $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" |
@@ -455,6 +497,7 b' check that we can merge tags that differ' | |||
|
455 | 497 | $ hg up -qC |
|
456 | 498 | |
|
457 | 499 | $ hg tag --remove t5 |
|
500 | hook: tag changes detected | |
|
458 | 501 | $ echo c4 > f4 |
|
459 | 502 | $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n" |
|
460 | 503 | 2 changes since t4:t6 |
@@ -473,7 +516,9 b' check that we can merge tags that differ' | |||
|
473 | 516 | $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n" |
|
474 | 517 | 4 changes since t4:t6 |
|
475 | 518 | $ hg tag t2 |
|
519 | hook: tag changes detected | |
|
476 | 520 | $ hg tag -f t6 |
|
521 | hook: tag changes detected | |
|
477 | 522 | |
|
478 | 523 | $ cd ../repo-automatic-tag-merge-clone |
|
479 | 524 | $ hg pull |
@@ -483,6 +528,7 b' check that we can merge tags that differ' | |||
|
483 | 528 | adding manifests |
|
484 | 529 | adding file changes |
|
485 | 530 | added 6 changesets with 6 changes to 3 files (+1 heads) |
|
531 | hook: tag changes detected | |
|
486 | 532 |
|
|
487 | 533 | $ hg merge --tool internal:tagmerge |
|
488 | 534 | merging .hgtags |
@@ -543,10 +589,12 b' detect merge tag conflicts' | |||
|
543 | 589 | $ hg update -C -r tip |
|
544 | 590 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
545 | 591 | $ hg tag t7 |
|
592 | hook: tag changes detected | |
|
546 | 593 | $ hg update -C -r 'first(sort(head()))' |
|
547 | 594 | 3 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
548 | 595 | $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags |
|
549 | 596 | $ hg commit -m "manually add conflicting t7 tag" |
|
597 | hook: tag changes detected | |
|
550 | 598 | $ hg merge --tool internal:tagmerge |
|
551 | 599 | merging .hgtags |
|
552 | 600 | automatic .hgtags merge failed |
@@ -581,11 +629,13 b' handle the loss of tags' | |||
|
581 | 629 | $ hg ci -A -m5 |
|
582 | 630 | adding f5 |
|
583 | 631 | $ hg tag -f t7 |
|
632 | hook: tag changes detected | |
|
584 | 633 | $ hg update -r 'p1(t7)' |
|
585 | 634 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
586 | 635 | $ printf '' > .hgtags |
|
587 | 636 | $ hg commit -m 'delete all tags' |
|
588 | 637 | created new head |
|
638 | hook: tag changes detected | |
|
589 | 639 | $ hg log -r 'max(t7::)' |
|
590 | 640 | changeset: 17:ffe462b50880 |
|
591 | 641 | user: test |
General Comments 0
You need to be logged in to leave comments.
Login now