##// END OF EJS Templates
track-tags: write all tag changes to a file...
Pierre-Yves David -
r31996:e6e1884d default
parent child Browse files
Show More
@@ -1015,6 +1015,25 b' class localrepository(object):'
1015 # and do not use caches as much as it could. The current focus is on
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
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.
1017 # will be removed when we are happy with the performance impact.
1018 #
1019 # Once this feature is no longer experimental move the following
1020 # documentation to the appropriate help section:
1021 #
1022 # The ``HG_TAG_MOVED`` variable will be set if the transaction touched
1023 # tags (new or changed or deleted tags). In addition the details of
1024 # these changes are made available in a file at:
1025 # ``REPOROOT/.hg/changes/tags.changes``.
1026 # Make sure you check for HG_TAG_MOVED before reading that file as it
1027 # might exist from a previous transaction even if no tag were touched
1028 # in this one. Changes are recorded in a line base format::
1029 #
1030 # <action> <hex-node> <tag-name>\n
1031 #
1032 # Actions are defined as follow:
1033 # "-R": tag is removed,
1034 # "+A": tag is added,
1035 # "-M": tag is moved (old value),
1036 # "+M": tag is moved (new value),
1018 tracktags = lambda x: None
1037 tracktags = lambda x: None
1019 # experimental config: experimental.hook-track-tags
1038 # experimental config: experimental.hook-track-tags
1020 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags',
1039 shouldtracktags = self.ui.configbool('experimental', 'hook-track-tags',
@@ -1031,6 +1050,12 b' class localrepository(object):'
1031 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1050 changes = tagsmod.difftags(repo.ui, repo, oldfnodes, newfnodes)
1032 if changes:
1051 if changes:
1033 tr2.hookargs['tag_moved'] = '1'
1052 tr2.hookargs['tag_moved'] = '1'
1053 with repo.vfs('changes/tags.changes', 'w',
1054 atomictemp=True) as changesfile:
1055 # note: we do not register the file to the transaction
1056 # because we needs it to still exist on the transaction
1057 # is close (for txnclose hooks)
1058 tagsmod.writediff(changesfile, changes)
1034 def validate(tr2):
1059 def validate(tr2):
1035 """will run pre-closing hooks"""
1060 """will run pre-closing hooks"""
1036 # XXX the transaction API is a bit lacking here so we take a hacky
1061 # XXX the transaction API is a bit lacking here so we take a hacky
@@ -129,6 +129,44 b' def difftags(ui, repo, oldfnodes, newfno'
129 entries.sort()
129 entries.sort()
130 return entries
130 return entries
131
131
132 def writediff(fp, difflist):
133 """write tags diff information to a file.
134
135 Data are stored with a line based format:
136
137 <action> <hex-node> <tag-name>\n
138
139 Action are defined as follow:
140 -R tag is removed,
141 +A tag is added,
142 -M tag is moved (old value),
143 +M tag is moved (new value),
144
145 Example:
146
147 +A 875517b4806a848f942811a315a5bce30804ae85 t5
148
149 See documentation of difftags output for details about the input.
150 """
151 add = '+A %s %s\n'
152 remove = '-R %s %s\n'
153 updateold = '-M %s %s\n'
154 updatenew = '+M %s %s\n'
155 for tag, old, new in difflist:
156 # translate to hex
157 if old is not None:
158 old = hex(old)
159 if new is not None:
160 new = hex(new)
161 # write to file
162 if old is None:
163 fp.write(add % (new, tag))
164 elif new is None:
165 fp.write(remove % (old, tag))
166 else:
167 fp.write(updateold % (old, tag))
168 fp.write(updatenew % (new, tag))
169
132 def findglobaltags(ui, repo):
170 def findglobaltags(ui, repo):
133 '''Find global tags in a repo: return a tagsmap
171 '''Find global tags in a repo: return a tagsmap
134
172
@@ -11,6 +11,7 b''
11 > # file...
11 > # file...
12 > if [ -n "\$HG_TAG_MOVED" ]; then
12 > if [ -n "\$HG_TAG_MOVED" ]; then
13 > echo 'hook: tag changes detected'
13 > echo 'hook: tag changes detected'
14 > sed 's/^/hook: /' .hg/changes/tags.changes
14 > fi
15 > fi
15 > EOF
16 > EOF
16 $ chmod +x taghook.sh
17 $ chmod +x taghook.sh
@@ -37,6 +38,7 b' specified)'
37
38
38 $ HGEDITOR=cat hg tag "bleah"
39 $ HGEDITOR=cat hg tag "bleah"
39 hook: tag changes detected
40 hook: tag changes detected
41 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
40 $ hg history
42 $ hg history
41 changeset: 1:d4f0d2909abc
43 changeset: 1:d4f0d2909abc
42 tag: tip
44 tag: tip
@@ -86,13 +88,21 b' specified)'
86
88
87 $ hg tag -r 0 "bleah0"
89 $ hg tag -r 0 "bleah0"
88 hook: tag changes detected
90 hook: tag changes detected
91 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0
89 $ hg tag -l -r 1 "bleah1"
92 $ hg tag -l -r 1 "bleah1"
90 $ hg tag gack gawk gorp
93 $ hg tag gack gawk gorp
91 hook: tag changes detected
94 hook: tag changes detected
95 hook: +A 336fccc858a4eb69609a291105009e484a6b6b8d gack
96 hook: +A 336fccc858a4eb69609a291105009e484a6b6b8d gawk
97 hook: +A 336fccc858a4eb69609a291105009e484a6b6b8d gorp
92 $ hg tag -f gack
98 $ hg tag -f gack
93 hook: tag changes detected
99 hook: tag changes detected
100 hook: -M 336fccc858a4eb69609a291105009e484a6b6b8d gack
101 hook: +M 799667b6f2d9b957f73fa644a918c2df22bab58f gack
94 $ hg tag --remove gack gorp
102 $ hg tag --remove gack gorp
95 hook: tag changes detected
103 hook: tag changes detected
104 hook: -R 799667b6f2d9b957f73fa644a918c2df22bab58f gack
105 hook: -R 336fccc858a4eb69609a291105009e484a6b6b8d gorp
96
106
97 $ hg tag "bleah "
107 $ hg tag "bleah "
98 abort: tag 'bleah' already exists (use -f to force)
108 abort: tag 'bleah' already exists (use -f to force)
@@ -105,8 +115,10 b' specified)'
105 [255]
115 [255]
106 $ hg tag -r 0 " bleahbleah "
116 $ hg tag -r 0 " bleahbleah "
107 hook: tag changes detected
117 hook: tag changes detected
118 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleahbleah
108 $ hg tag -r 0 " bleah bleah "
119 $ hg tag -r 0 " bleah bleah "
109 hook: tag changes detected
120 hook: tag changes detected
121 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah bleah
110
122
111 $ cat .hgtags
123 $ cat .hgtags
112 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
124 acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
@@ -136,6 +148,7 b' tagging on a non-head revision'
136 [255]
148 [255]
137 $ hg tag -f "foobar"
149 $ hg tag -f "foobar"
138 hook: tag changes detected
150 hook: tag changes detected
151 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
139 $ cat .hgtags
152 $ cat .hgtags
140 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
153 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
141 $ cat .hg/localtags
154 $ cat .hg/localtags
@@ -194,18 +207,23 b' cloning local tags'
194
207
195 $ hg clone -q -rbleah1 test test1
208 $ hg clone -q -rbleah1 test test1
196 hook: tag changes detected
209 hook: tag changes detected
210 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
197 $ hg -R test1 parents --style=compact
211 $ hg -R test1 parents --style=compact
198 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test
212 1[tip] d4f0d2909abc 1970-01-01 00:00 +0000 test
199 Added tag bleah for changeset acb14030fe0a
213 Added tag bleah for changeset acb14030fe0a
200
214
201 $ hg clone -q -r5 test#bleah1 test2
215 $ hg clone -q -r5 test#bleah1 test2
202 hook: tag changes detected
216 hook: tag changes detected
217 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
218 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0
219 hook: +A 336fccc858a4eb69609a291105009e484a6b6b8d gawk
203 $ hg -R test2 parents --style=compact
220 $ hg -R test2 parents --style=compact
204 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test
221 5[tip] b4bb47aaff09 1970-01-01 00:00 +0000 test
205 Removed tag gack, gorp
222 Removed tag gack, gorp
206
223
207 $ hg clone -q -U test#bleah1 test3
224 $ hg clone -q -U test#bleah1 test3
208 hook: tag changes detected
225 hook: tag changes detected
226 hook: +A acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
209 $ hg -R test3 parents --style=compact
227 $ hg -R test3 parents --style=compact
210
228
211 $ cd test
229 $ cd test
@@ -234,6 +252,7 b" doesn't end with EOL"
234 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
252 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
235 $ hg tag newline
253 $ hg tag newline
236 hook: tag changes detected
254 hook: tag changes detected
255 hook: +A a0eea09de1eeec777b46f2085260a373b2fbc293 newline
237 $ cat .hgtags; echo
256 $ cat .hgtags; echo
238 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
257 acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
239 a0eea09de1eeec777b46f2085260a373b2fbc293 newline
258 a0eea09de1eeec777b46f2085260a373b2fbc293 newline
@@ -248,6 +267,7 b' tag and branch using same name'
248 $ hg tag tag-and-branch-same-name
267 $ hg tag tag-and-branch-same-name
249 warning: tag tag-and-branch-same-name conflicts with existing branch name
268 warning: tag tag-and-branch-same-name conflicts with existing branch name
250 hook: tag changes detected
269 hook: tag changes detected
270 hook: +A fc93d2ea1cd78e91216c6cfbbf26747c10ce11ae tag-and-branch-same-name
251
271
252 test custom commit messages
272 test custom commit messages
253
273
@@ -333,6 +353,7 b' then, test custom commit message itself'
333 HG: changed .hgtags
353 HG: changed .hgtags
334 ====
354 ====
335 hook: tag changes detected
355 hook: tag changes detected
356 hook: +A 75a534207be6b03576e0c7a4fa5708d045f1c876 custom-tag
336 $ hg log -l1 --template "{desc}\n"
357 $ hg log -l1 --template "{desc}\n"
337 custom tag message
358 custom tag message
338 second line
359 second line
@@ -342,6 +363,7 b' local tag with .hgtags modified'
342
363
343 $ hg tag hgtags-modified
364 $ hg tag hgtags-modified
344 hook: tag changes detected
365 hook: tag changes detected
366 hook: +A 0f26aaea6f74c3ed6c4aad8844403c9ba128d23a hgtags-modified
345 $ hg rollback
367 $ hg rollback
346 repository tip rolled back to revision 13 (undo commit)
368 repository tip rolled back to revision 13 (undo commit)
347 working directory now based on revision 13
369 working directory now based on revision 13
@@ -362,10 +384,16 b" tagging when at named-branch-head that's"
362 (branch merge, don't forget to commit)
384 (branch merge, don't forget to commit)
363 $ hg ci -m 'merge named branch'
385 $ hg ci -m 'merge named branch'
364 hook: tag changes detected
386 hook: tag changes detected
387 hook: -R acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
388 hook: -R acb14030fe0a21b60322c440ad2d20cf7685a376 bleah bleah
389 hook: -R acb14030fe0a21b60322c440ad2d20cf7685a376 bleah0
390 hook: -R acb14030fe0a21b60322c440ad2d20cf7685a376 bleahbleah
391 hook: -R 336fccc858a4eb69609a291105009e484a6b6b8d gawk
365 $ hg up 13
392 $ hg up 13
366 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
393 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
367 $ hg tag new-topo-head
394 $ hg tag new-topo-head
368 hook: tag changes detected
395 hook: tag changes detected
396 hook: +A 0f26aaea6f74c3ed6c4aad8844403c9ba128d23a new-topo-head
369
397
370 tagging on null rev
398 tagging on null rev
371
399
@@ -433,6 +461,7 b' commit hook on tag used to be run withou'
433 > EOF
461 > EOF
434 $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag
462 $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag
435 hook: tag changes detected
463 hook: tag changes detected
464 hook: +A be090ea6625635128e90f7d89df8beeb2bcc1653 tag
436 pushing to $TESTTMP/repo-tag-target (glob)
465 pushing to $TESTTMP/repo-tag-target (glob)
437 searching for changes
466 searching for changes
438 adding changesets
467 adding changesets
@@ -440,6 +469,7 b' commit hook on tag used to be run withou'
440 adding file changes
469 adding file changes
441 added 2 changesets with 2 changes to 2 files
470 added 2 changesets with 2 changes to 2 files
442 hook: tag changes detected
471 hook: tag changes detected
472 hook: +A be090ea6625635128e90f7d89df8beeb2bcc1653 tag
443
473
444 automatically merge resolvable tag conflicts (i.e. tags that differ in rank)
474 automatically merge resolvable tag conflicts (i.e. tags that differ in rank)
445 create two clones with some different tags as well as some common tags
475 create two clones with some different tags as well as some common tags
@@ -452,6 +482,7 b' check that we can merge tags that differ'
452 adding f0
482 adding f0
453 $ hg tag tbase
483 $ hg tag tbase
454 hook: tag changes detected
484 hook: tag changes detected
485 hook: +A 6cee5c8f3e5b4ae1a3996d2f6489c3e08eb5aea7 tbase
455 $ hg up -qr '.^'
486 $ hg up -qr '.^'
456 $ hg log -r 'wdir()' -T "{latesttagdistance}\n"
487 $ hg log -r 'wdir()' -T "{latesttagdistance}\n"
457 1
488 1
@@ -468,15 +499,22 b' check that we can merge tags that differ'
468 adding f1
499 adding f1
469 $ hg tag t1 t2 t3
500 $ hg tag t1 t2 t3
470 hook: tag changes detected
501 hook: tag changes detected
502 hook: +A 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t1
503 hook: +A 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2
504 hook: +A 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3
471 $ hg tag --remove t2
505 $ hg tag --remove t2
472 hook: tag changes detected
506 hook: tag changes detected
507 hook: -R 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t2
473 $ hg tag t5
508 $ hg tag t5
474 hook: tag changes detected
509 hook: tag changes detected
510 hook: +A 875517b4806a848f942811a315a5bce30804ae85 t5
475 $ echo c2 > f2
511 $ echo c2 > f2
476 $ hg ci -A -m2
512 $ hg ci -A -m2
477 adding f2
513 adding f2
478 $ hg tag -f t3
514 $ hg tag -f t3
479 hook: tag changes detected
515 hook: tag changes detected
516 hook: -M 4f3e9b90005b68b4d8a3f4355cedc302a8364f5c t3
517 hook: +M 79505d5360b07e3e79d1052e347e73c02b8afa5b t3
480
518
481 $ cd ../repo-automatic-tag-merge
519 $ cd ../repo-automatic-tag-merge
482 $ echo c3 > f3
520 $ echo c3 > f3
@@ -484,6 +522,9 b' check that we can merge tags that differ'
484 adding f3
522 adding f3
485 $ hg tag -f t4 t5 t6
523 $ hg tag -f t4 t5 t6
486 hook: tag changes detected
524 hook: tag changes detected
525 hook: +A 9aa4e1292a27a248f8d07339bed9931d54907be7 t4
526 hook: +A 9aa4e1292a27a248f8d07339bed9931d54907be7 t5
527 hook: +A 9aa4e1292a27a248f8d07339bed9931d54907be7 t6
487
528
488 $ hg up -q '.^'
529 $ hg up -q '.^'
489 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n"
530 $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n"
@@ -497,6 +538,7 b' check that we can merge tags that differ'
497
538
498 $ hg tag --remove t5
539 $ hg tag --remove t5
499 hook: tag changes detected
540 hook: tag changes detected
541 hook: -R 9aa4e1292a27a248f8d07339bed9931d54907be7 t5
500 $ echo c4 > f4
542 $ echo c4 > f4
501 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n"
543 $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n"
502 2 changes since t4:t6
544 2 changes since t4:t6
@@ -516,8 +558,11 b' check that we can merge tags that differ'
516 4 changes since t4:t6
558 4 changes since t4:t6
517 $ hg tag t2
559 $ hg tag t2
518 hook: tag changes detected
560 hook: tag changes detected
561 hook: +A 929bca7b18d067cbf3844c3896319a940059d748 t2
519 $ hg tag -f t6
562 $ hg tag -f t6
520 hook: tag changes detected
563 hook: tag changes detected
564 hook: -M 9aa4e1292a27a248f8d07339bed9931d54907be7 t6
565 hook: +M 09af2ce14077a94effef208b49a718f4836d4338 t6
521
566
522 $ cd ../repo-automatic-tag-merge-clone
567 $ cd ../repo-automatic-tag-merge-clone
523 $ hg pull
568 $ hg pull
@@ -528,6 +573,10 b' check that we can merge tags that differ'
528 adding file changes
573 adding file changes
529 added 6 changesets with 6 changes to 3 files (+1 heads)
574 added 6 changesets with 6 changes to 3 files (+1 heads)
530 hook: tag changes detected
575 hook: tag changes detected
576 hook: +A 929bca7b18d067cbf3844c3896319a940059d748 t2
577 hook: +A 9aa4e1292a27a248f8d07339bed9931d54907be7 t4
578 hook: -R 875517b4806a848f942811a315a5bce30804ae85 t5
579 hook: +A 09af2ce14077a94effef208b49a718f4836d4338 t6
531 (run 'hg heads' to see heads, 'hg merge' to merge)
580 (run 'hg heads' to see heads, 'hg merge' to merge)
532 $ hg merge --tool internal:tagmerge
581 $ hg merge --tool internal:tagmerge
533 merging .hgtags
582 merging .hgtags
@@ -589,11 +638,16 b' detect merge tag conflicts'
589 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
638 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
590 $ hg tag t7
639 $ hg tag t7
591 hook: tag changes detected
640 hook: tag changes detected
641 hook: +A b325cc5b642c5b465bdbe8c09627cb372de3d47d t7
592 $ hg update -C -r 'first(sort(head()))'
642 $ hg update -C -r 'first(sort(head()))'
593 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
643 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
594 $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags
644 $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags
595 $ hg commit -m "manually add conflicting t7 tag"
645 $ hg commit -m "manually add conflicting t7 tag"
596 hook: tag changes detected
646 hook: tag changes detected
647 hook: -R 929bca7b18d067cbf3844c3896319a940059d748 t2
648 hook: +A 875517b4806a848f942811a315a5bce30804ae85 t5
649 hook: -M b325cc5b642c5b465bdbe8c09627cb372de3d47d t7
650 hook: +M ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7
597 $ hg merge --tool internal:tagmerge
651 $ hg merge --tool internal:tagmerge
598 merging .hgtags
652 merging .hgtags
599 automatic .hgtags merge failed
653 automatic .hgtags merge failed
@@ -629,6 +683,8 b' handle the loss of tags'
629 adding f5
683 adding f5
630 $ hg tag -f t7
684 $ hg tag -f t7
631 hook: tag changes detected
685 hook: tag changes detected
686 hook: -M ea918d56be86a4afc5a95312e8b6750e1428d9d2 t7
687 hook: +M fd3a9e394ce3afb354a496323bf68ac1755a30de t7
632 $ hg update -r 'p1(t7)'
688 $ hg update -r 'p1(t7)'
633 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
689 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
634 $ printf '' > .hgtags
690 $ printf '' > .hgtags
General Comments 0
You need to be logged in to leave comments. Login now