diff 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
line wrap: on
line diff
--- a/tests/test-tag.t	Tue Mar 28 05:06:56 2017 +0200
+++ b/tests/test-tag.t	Tue Mar 28 06:38:09 2017 +0200
@@ -1,3 +1,19 @@
+  $ cat >> $HGRCPATH << EOF
+  > [experimental]
+  > hook-track-tags=1
+  > [hooks]
+  > txnclose.track-tag=${TESTTMP}/taghook.sh
+  > EOF
+
+  $ cat << EOF > taghook.sh
+  > #!/bin/sh
+  > # escape the "$" otherwise the test runner interpret it when writting the
+  > # file...
+  > if [ -n "\$HG_TAG_MOVED" ]; then
+  >     echo 'hook: tag changes detected'
+  > fi
+  > EOF
+  $ chmod +x taghook.sh
   $ hg init test
   $ cd test
 
@@ -20,6 +36,7 @@
 specified)
 
   $ HGEDITOR=cat hg tag "bleah"
+  hook: tag changes detected
   $ hg history
   changeset:   1:d4f0d2909abc
   tag:         tip
@@ -68,10 +85,14 @@
   [255]
 
   $ hg tag -r 0 "bleah0"
+  hook: tag changes detected
   $ hg tag -l -r 1 "bleah1"
   $ hg tag gack gawk gorp
+  hook: tag changes detected
   $ hg tag -f gack
+  hook: tag changes detected
   $ hg tag --remove gack gorp
+  hook: tag changes detected
 
   $ hg tag "bleah "
   abort: tag 'bleah' already exists (use -f to force)
@@ -83,7 +104,9 @@
   abort: tag 'bleah' already exists (use -f to force)
   [255]
   $ hg tag -r 0 "  bleahbleah  "
+  hook: tag changes detected
   $ hg tag -r 0 " bleah bleah "
+  hook: tag changes detected
 
   $ cat .hgtags
   acb14030fe0a21b60322c440ad2d20cf7685a376 bleah
@@ -112,6 +135,7 @@
   abort: working directory is not at a branch head (use -f to force)
   [255]
   $ hg tag -f "foobar"
+  hook: tag changes detected
   $ cat .hgtags
   acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
   $ cat .hg/localtags
@@ -169,16 +193,19 @@
   summary:     Removed tag gack, gorp
   
   $ hg clone -q -rbleah1 test test1
+  hook: tag changes detected
   $ hg -R test1 parents --style=compact
   1[tip]   d4f0d2909abc   1970-01-01 00:00 +0000   test
     Added tag bleah for changeset acb14030fe0a
   
   $ hg clone -q -r5 test#bleah1 test2
+  hook: tag changes detected
   $ hg -R test2 parents --style=compact
   5[tip]   b4bb47aaff09   1970-01-01 00:00 +0000   test
     Removed tag gack, gorp
   
   $ hg clone -q -U test#bleah1 test3
+  hook: tag changes detected
   $ hg -R test3 parents --style=compact
 
   $ cd test
@@ -203,9 +230,11 @@
   > f = file('.hgtags', 'w'); f.write(last); f.close()
   > EOF
   $ hg ci -m'broken manual edit of .hgtags'
+  hook: tag changes detected
   $ cat .hgtags; echo
   acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
   $ hg tag newline
+  hook: tag changes detected
   $ cat .hgtags; echo
   acb14030fe0a21b60322c440ad2d20cf7685a376 foobar
   a0eea09de1eeec777b46f2085260a373b2fbc293 newline
@@ -219,6 +248,7 @@
   $ hg ci -m"discouraged"
   $ hg tag tag-and-branch-same-name
   warning: tag tag-and-branch-same-name conflicts with existing branch name
+  hook: tag changes detected
 
 test custom commit messages
 
@@ -303,6 +333,7 @@
   HG: branch 'tag-and-branch-same-name'
   HG: changed .hgtags
   ====
+  hook: tag changes detected
   $ hg log -l1 --template "{desc}\n"
   custom tag message
   second line
@@ -311,6 +342,7 @@
 local tag with .hgtags modified
 
   $ hg tag hgtags-modified
+  hook: tag changes detected
   $ hg rollback
   repository tip rolled back to revision 13 (undo commit)
   working directory now based on revision 13
@@ -330,9 +362,11 @@
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg ci -m 'merge named branch'
+  hook: tag changes detected
   $ hg up 13
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tag new-topo-head
+  hook: tag changes detected
 
 tagging on null rev
 
@@ -399,12 +433,14 @@
   > hg push "$TESTTMP/repo-tag-target"
   > EOF
   $ hg -R repo-tag --config hooks.commit="sh ../issue3344.sh" tag tag
+  hook: tag changes detected
   pushing to $TESTTMP/repo-tag-target (glob)
   searching for changes
   adding changesets
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 2 files
+  hook: tag changes detected
 
 automatically merge resolvable tag conflicts (i.e. tags that differ in rank)
 create two clones with some different tags as well as some common tags
@@ -416,6 +452,7 @@
   $ hg ci -A -m0
   adding f0
   $ hg tag tbase
+  hook: tag changes detected
   $ hg up -qr '.^'
   $ hg log -r 'wdir()' -T "{latesttagdistance}\n"
   1
@@ -431,18 +468,23 @@
   $ hg ci -A -m1
   adding f1
   $ hg tag t1 t2 t3
+  hook: tag changes detected
   $ hg tag --remove t2
+  hook: tag changes detected
   $ hg tag t5
+  hook: tag changes detected
   $ echo c2 > f2
   $ hg ci -A -m2
   adding f2
   $ hg tag -f t3
+  hook: tag changes detected
 
   $ cd ../repo-automatic-tag-merge
   $ echo c3 > f3
   $ hg ci -A -m3
   adding f3
   $ hg tag -f t4 t5 t6
+  hook: tag changes detected
 
   $ hg up -q '.^'
   $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n"
@@ -455,6 +497,7 @@
   $ hg up -qC
 
   $ hg tag --remove t5
+  hook: tag changes detected
   $ echo c4 > f4
   $ hg log -r '.' -T "{changessincelatesttag} changes since {latesttag}\n"
   2 changes since t4:t6
@@ -473,7 +516,9 @@
   $ hg log -r 'wdir()' -T "{changessincelatesttag} changes since {latesttag}\n"
   4 changes since t4:t6
   $ hg tag t2
+  hook: tag changes detected
   $ hg tag -f t6
+  hook: tag changes detected
 
   $ cd ../repo-automatic-tag-merge-clone
   $ hg pull
@@ -483,6 +528,7 @@
   adding manifests
   adding file changes
   added 6 changesets with 6 changes to 3 files (+1 heads)
+  hook: tag changes detected
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg merge --tool internal:tagmerge
   merging .hgtags
@@ -543,10 +589,12 @@
   $ hg update -C -r tip
   3 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ hg tag t7
+  hook: tag changes detected
   $ hg update -C -r 'first(sort(head()))'
   3 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ printf "%s %s\n" `hg log -r . --template "{node} t7"` >> .hgtags
   $ hg commit -m "manually add conflicting t7 tag"
+  hook: tag changes detected
   $ hg merge --tool internal:tagmerge
   merging .hgtags
   automatic .hgtags merge failed
@@ -581,11 +629,13 @@
   $ hg ci -A -m5
   adding f5
   $ hg tag -f t7
+  hook: tag changes detected
   $ hg update -r 'p1(t7)'
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ printf '' > .hgtags
   $ hg commit -m 'delete all tags'
   created new head
+  hook: tag changes detected
   $ hg log -r 'max(t7::)'
   changeset:   17:ffe462b50880
   user:        test