tags: write a separate tags cache file for unfiltered repos
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 16 Apr 2015 11:54:13 -0400
changeset 24762 1062663808ce
parent 24761 61a6d83280d3
child 24763 a698e088ad29
tags: write a separate tags cache file for unfiltered repos Since we changed the format of the tags cache, we should bump the filename. Before this patch, "tags" was being used for unfiltered repositories. Change the naming scheme to be consistent and ensure that a new cache file is used. While I was here, I updated the docs to describe the existence of multiple caches. I also added explicit test coverage for the creation of the unfiltered tags cache.
mercurial/tags.py
tests/test-obsolete-tag-cache.t
tests/test-tags.t
--- a/mercurial/tags.py	Thu Apr 16 11:32:46 2015 -0400
+++ b/mercurial/tags.py	Thu Apr 16 11:54:13 2015 -0400
@@ -36,10 +36,11 @@
 # repositories with very large manifests. Multiplied by dozens or even
 # hundreds of heads and there is a significant performance concern.
 #
-# The "tags" cache stores information about the history of tags.
+# There also exist a separate cache file for each repository filter.
+# These "tags-*" files store information about the history of tags.
 #
-# The cache file consists of a cache validation line followed by a history
-# of tags.
+# The tags cache files consists of a cache validation line followed by
+# a history of tags.
 #
 # The cache validation line has the format:
 #
@@ -239,7 +240,7 @@
 
 def _filename(repo):
     """name of a tagcache file for a given repo or repoview"""
-    filename = 'cache/tags'
+    filename = 'cache/tags2'
     if repo.filtername:
         filename = '%s-%s' % (filename, repo.filtername)
     return filename
--- a/tests/test-obsolete-tag-cache.t	Thu Apr 16 11:32:46 2015 -0400
+++ b/tests/test-obsolete-tag-cache.t	Thu Apr 16 11:54:13 2015 -0400
@@ -47,7 +47,7 @@
   test2                              2:d75775ffbc6b
   test1                              0:55482a6fb4b1
 
-  $ cat .hg/cache/tags-visible
+  $ cat .hg/cache/tags2-visible
   5 2942a772f72a444bef4bef13874d515f50fa27b6
   042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
   55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
@@ -62,7 +62,7 @@
   head2                              4:042eb6bfcc49
   test1                              0:55482a6fb4b1
 
-  $ cat .hg/cache/tags-visible
+  $ cat .hg/cache/tags2-visible
   5 2942a772f72a444bef4bef13874d515f50fa27b6 f34fbc9a9769ba9eff5aff3d008a6b49f85c08b1
   042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
   55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
@@ -82,7 +82,7 @@
   tip                                5:2942a772f72a
   head2                              4:042eb6bfcc49
 
-  $ cat .hg/cache/tags-visible
+  $ cat .hg/cache/tags2-visible
   5 2942a772f72a444bef4bef13874d515f50fa27b6 2fce1eec33263d08a4d04293960fc73a555230e4
   042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
 
@@ -91,3 +91,23 @@
   1970/01/01 00:00:00 bob> 1/1 cache hits/lookups in * seconds (glob)
   1970/01/01 00:00:00 bob> writing tags cache file with 1 tags
   1970/01/01 00:00:00 bob> tags exited 0 after * seconds (glob)
+
+Resolving tags on an unfiltered repo writes a separate tags cache
+
+  $ hg --hidden tags
+  tip                                5:2942a772f72a
+  head2                              4:042eb6bfcc49
+  test2                              2:d75775ffbc6b
+  test1                              0:55482a6fb4b1
+
+  $ cat .hg/cache/tags2
+  5 2942a772f72a444bef4bef13874d515f50fa27b6
+  042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 head2
+  55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1
+  d75775ffbc6bca1794d300f5571272879bd280da test2
+
+  $ hg blackbox -l 4
+  1970/01/01 00:00:00 bob> --hidden tags
+  1970/01/01 00:00:00 bob> 2/2 cache hits/lookups in * seconds (glob)
+  1970/01/01 00:00:00 bob> writing tags cache file with 3 tags
+  1970/01/01 00:00:00 bob> --hidden tags exited 0 after * seconds (glob)
--- a/tests/test-tags.t	Thu Apr 16 11:32:46 2015 -0400
+++ b/tests/test-tags.t	Thu Apr 16 11:54:13 2015 -0400
@@ -9,7 +9,7 @@
 Helper functions:
 
   $ cacheexists() {
-  >   [ -f .hg/cache/tags-visible ] && echo "tag cache exists" || echo "no tag cache"
+  >   [ -f .hg/cache/tags2-visible ] && echo "tag cache exists" || echo "no tag cache"
   > }
 
   $ fnodescacheexists() {
@@ -56,7 +56,7 @@
 
 Try corrupting the cache
 
-  $ printf 'a b' > .hg/cache/tags-visible
+  $ printf 'a b' > .hg/cache/tags2-visible
   $ hg identify
   acb14030fe0a tip
   $ cacheexists
@@ -102,7 +102,7 @@
 
 Repeat with cold tag cache:
 
-  $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1
+  $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ hg identify
   b9154636be93 tip
 
@@ -117,7 +117,7 @@
 And again, but now unable to write tag cache:
 
 #if unix-permissions
-  $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1
+  $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ chmod 555 .hg/cache
   $ hg identify
   b9154636be93 tip
@@ -126,7 +126,7 @@
 
 Tag cache debug info written to blackbox log
 
-  $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1
+  $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ hg identify
   b9154636be93 tip
   $ hg blackbox -l 5
@@ -138,7 +138,7 @@
 
 Failure to acquire lock results in no write
 
-  $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1
+  $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ echo 'foo:1' > .hg/wlock
   $ hg identify
   b9154636be93 tip
@@ -154,7 +154,7 @@
 
   $ rm .hg/wlock
 
-  $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1
+  $ rm -f .hg/cache/tags2-visible .hg/cache/hgtagsfnodes1
   $ hg identify
   b9154636be93 tip
 
@@ -311,7 +311,7 @@
 
 Dump cache:
 
-  $ cat .hg/cache/tags-visible
+  $ cat .hg/cache/tags2-visible
   4 0c192d7d5e6b78a714de54a2e9627952a877e25a
   bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
   bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
@@ -353,7 +353,7 @@
   $ hg commit -m throwaway2
 
   $ chmod a-w .hg/cache/hgtagsfnodes1
-  $ rm -f .hg/cache/tags-visible
+  $ rm -f .hg/cache/tags2-visible
 
   $ hg tags
   tip                                6:b968051b5cf3
@@ -369,7 +369,7 @@
   $ chmod a+w .hg/cache/hgtagsfnodes1
 #endif
 
-  $ rm -f .hg/cache/tags-visible
+  $ rm -f .hg/cache/tags2-visible
   $ hg tags
   tip                                6:b968051b5cf3
   bar                                1:78391a272241
@@ -521,7 +521,7 @@
   $ hg tags                  # partly stale
   tip                                4:735c3ca72986
   bar                                0:bbd179dfa0a7
-  $ rm -f .hg/cache/tags-visible
+  $ rm -f .hg/cache/tags2-visible
   $ hg tags                  # cold cache
   tip                                4:735c3ca72986
   bar                                0:bbd179dfa0a7