[PATCH 02 of 10] test-tags: enhance the test to probe tag caching better (issue548)

Greg Ward greg-hg at gerg.ca
Thu Jul 16 09:42:48 CDT 2009


# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1247755181 14400
# Node ID e793052d08046f1d8bc0c12cf2ae081d37af5e83
# Parent  ee70b0b5531e322a453ee63fe3904f9751b675b1
test-tags: enhance the test to probe tag caching better (issue548).

- give detailed dumps of .hgtags and localtags content
- repeat some query operations to expose cache bugs
- ensure that rollback/strip undo tagging operations

diff --git a/tests/test-tags b/tests/test-tags
--- a/tests/test-tags
+++ b/tests/test-tags
@@ -90,16 +90,38 @@
 echo >> foo
 hg ci -m 'change foo 2' # rev 4
 hg tags
+hg tags         # repeat in case of cache effects
+
+dumptags() {
+    rev=$1
+    echo "rev $rev: .hgtags:"
+    hg cat -r$rev .hgtags
+}
+
+echo "% detailed dump of tag info"
+echo "heads:"
+hg heads -q             # expect 4, 3, 2
+dumptags 2
+dumptags 3
+dumptags 4
+echo ".hg/tags.cache:"
+[ -f .hg/tags.cache ] && cat .hg/tags.cache || echo "no such file"
 
 echo "% test tag removal"
 hg tag --remove bar     # rev 5
 hg tip -vp
 hg tags
+hg tags                 # again, try to expose cache bugs
 
 echo '% remove nonexistent tag'
 hg tag --remove foobar
 hg tip
 
+echo "% rollback undoes tag operation"
+hg rollback             # destroy rev 5 (restore bar)
+hg tags
+hg tags
+
 echo "% test tag rank"
 cd ..
 hg init t3
@@ -122,6 +144,16 @@
 hg tag -r 3 bar
 hg tags
 
+echo "% strip 1: expose an old head"
+hg --config extensions.mq= strip 5 > /dev/null 2>&1
+hg tags                  # partly stale cache
+hg tags                  # up-to-date cache
+echo "% strip 2: destroy whole branch, no old head exposed"
+hg --config extensions.mq= strip 4 > /dev/null 2>&1 
+hg tags                  # partly stale
+rm -f .hg/tags.cache
+hg tags                  # cold cache
+
 echo "% test tag rank with 3 heads"
 cd ..
 hg init t4
diff --git a/tests/test-tags.out b/tests/test-tags.out
--- a/tests/test-tags.out
+++ b/tests/test-tags.out
@@ -57,6 +57,23 @@
 created new head
 tip                                4:0c192d7d5e6b
 bar                                1:78391a272241
+tip                                4:0c192d7d5e6b
+bar                                1:78391a272241
+% detailed dump of tag info
+heads:
+4:0c192d7d5e6b
+3:6fa450212aeb
+2:7a94127795a3
+rev 2: .hgtags:
+bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
+rev 3: .hgtags:
+bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
+bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
+78391a272241d70354aa14c874552cad6b51bb42 bar
+rev 4: .hgtags:
+bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
+.hg/tags.cache:
+no such file
 % test tag removal
 changeset:   5:5f6e8655b1c7
 tag:         tip
@@ -76,6 +93,7 @@
 +0000000000000000000000000000000000000000 bar
 
 tip                                5:5f6e8655b1c7
+tip                                5:5f6e8655b1c7
 % remove nonexistent tag
 abort: tag 'foobar' does not exist
 changeset:   5:5f6e8655b1c7
@@ -84,6 +102,12 @@
 date:        Thu Jan 01 00:00:00 1970 +0000
 summary:     Removed tag bar
 
+% rollback undoes tag operation
+rolling back last transaction
+tip                                4:0c192d7d5e6b
+bar                                1:78391a272241
+tip                                4:0c192d7d5e6b
+bar                                1:78391a272241
 % test tag rank
 tip                                5:85f05169d91d
 bar                                0:bbd179dfa0a7
@@ -95,6 +119,16 @@
 abort: tag 'bar' already exists (use -f to force)
 tip                                6:735c3ca72986
 bar                                0:bbd179dfa0a7
+% strip 1: expose an old head
+tip                                5:735c3ca72986
+bar                                1:78391a272241
+tip                                5:735c3ca72986
+bar                                1:78391a272241
+% strip 2: destroy whole branch, no old head exposed
+tip                                4:735c3ca72986
+bar                                0:bbd179dfa0a7
+tip                                4:735c3ca72986
+bar                                0:bbd179dfa0a7
 % test tag rank with 3 heads
 adding foo
 tip                                3:197c21bbbf2c


More information about the Mercurial-devel mailing list