# HG changeset patch # User Pierre-Yves David # Date 1429137274 14400 # Node ID b061a2049662c5320c7a4af892c67ddd0dcb44d9 # Parent f2fd087a75ef4bce92746a1f4cd03661946b999f tags: have a different cache file per filter level Currently whichever filter level asks for tags last will write the data on disk. This create massive issues when tags are read for "visible" and "unfiltered" on large and multi headed repository (like Mozilla central). See issue4550 for details Each filter level recomputes its own cache without direct collaboration but they all share the same 'hgtagsfnodes' cache. And that is where most of the time is spent. diff -r f2fd087a75ef -r b061a2049662 mercurial/tags.py --- a/mercurial/tags.py Wed Apr 15 14:35:44 2015 -0700 +++ b/mercurial/tags.py Wed Apr 15 18:34:34 2015 -0400 @@ -246,6 +246,13 @@ ahist.extend([n for n in bhist if n not in ahist]) alltags[name] = anode, ahist +def _filename(repo): + """name of a tagcache file for a given repo or repoview""" + filename = 'cache/tags' + if repo.filtername: + filename = '%s-%s' % (filename, repo.filtername) + return filename + def _readtagcache(ui, repo): '''Read the tag cache. @@ -265,7 +272,7 @@ ''' try: - cachefile = repo.vfs('cache/tags', 'r') + cachefile = repo.vfs(_filename(repo), 'r') # force reading the file for static-http cachelines = iter(cachefile) except IOError: @@ -360,7 +367,7 @@ def _writetagcache(ui, repo, heads, tagfnode, cachetags): try: - cachefile = repo.vfs('cache/tags', 'w', atomictemp=True) + cachefile = repo.vfs(_filename(repo), 'w', atomictemp=True) except (OSError, IOError): return diff -r f2fd087a75ef -r b061a2049662 tests/test-mq.t --- a/tests/test-mq.t Wed Apr 15 14:35:44 2015 -0700 +++ b/tests/test-mq.t Wed Apr 15 18:34:34 2015 -0400 @@ -311,12 +311,12 @@ qpush with dump of tag cache Dump the tag cache to ensure that it has exactly one head after qpush. - $ rm -f .hg/cache/tags + $ rm -f .hg/cache/tags-visible $ hg tags > /dev/null -.hg/cache/tags (pre qpush): +.hg/cache/tags-visible (pre qpush): - $ cat .hg/cache/tags + $ cat .hg/cache/tags-visible 1 [\da-f]{40} (re) $ hg qpush @@ -326,9 +326,9 @@ 2: draft $ hg tags > /dev/null -.hg/cache/tags (post qpush): +.hg/cache/tags-visible (post qpush): - $ cat .hg/cache/tags + $ cat .hg/cache/tags-visible 2 [\da-f]{40} (re) $ checkundo qpush diff -r f2fd087a75ef -r b061a2049662 tests/test-obsolete-tag-cache.t --- a/tests/test-obsolete-tag-cache.t Wed Apr 15 14:35:44 2015 -0700 +++ b/tests/test-obsolete-tag-cache.t Wed Apr 15 18:34:34 2015 -0400 @@ -36,7 +36,7 @@ o 0:55482a6fb4b1 test1 initial - $ cat .hg/cache/tags + $ cat .hg/cache/tags-visible 4 042eb6bfcc4909bad84a1cbf6eb1ddf0ab587d41 3 c3cb30f2d2cd0aae008cc91a07876e3c5131fd22 b3bce87817fe7ac9dca2834366c1d7534c095cf1 @@ -62,7 +62,7 @@ .hgtags filenodes for hidden heads should be visible (issue4550) (currently broken) - $ cat .hg/cache/tags + $ cat .hg/cache/tags-visible 7 eb610439e10e0c6b296f97b59624c2e24fc59e30 b3bce87817fe7ac9dca2834366c1d7534c095cf1 55482a6fb4b1881fa8f746fd52cf6f096bb21c89 test1 diff -r f2fd087a75ef -r b061a2049662 tests/test-tags.t --- a/tests/test-tags.t Wed Apr 15 14:35:44 2015 -0700 +++ b/tests/test-tags.t Wed Apr 15 18:34:34 2015 -0400 @@ -9,7 +9,7 @@ Helper functions: $ cacheexists() { - > [ -f .hg/cache/tags ] && echo "tag cache exists" || echo "no tag cache" + > [ -f .hg/cache/tags-visible ] && echo "tag cache exists" || echo "no tag cache" > } $ fnodescacheexists() { @@ -56,7 +56,7 @@ Try corrupting the cache - $ printf 'a b' > .hg/cache/tags + $ printf 'a b' > .hg/cache/tags-visible $ hg identify acb14030fe0a tip $ cacheexists @@ -102,7 +102,7 @@ Repeat with cold tag cache: - $ rm -f .hg/cache/tags .hg/cache/hgtagsfnodes1 + $ rm -f .hg/cache/tags-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 .hg/cache/hgtagsfnodes1 + $ rm -f .hg/cache/tags-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 .hg/cache/hgtagsfnodes1 + $ rm -f .hg/cache/tags-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 .hg/cache/hgtagsfnodes1 + $ rm -f .hg/cache/tags-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 .hg/cache/hgtagsfnodes1 + $ rm -f .hg/cache/tags-visible .hg/cache/hgtagsfnodes1 $ hg identify b9154636be93 tip @@ -311,7 +311,7 @@ Dump cache: - $ cat .hg/cache/tags + $ cat .hg/cache/tags-visible 4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d 3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0 2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d @@ -356,7 +356,7 @@ $ hg commit -m throwaway2 $ chmod a-w .hg/cache/hgtagsfnodes1 - $ rm -f .hg/cache/tags + $ rm -f .hg/cache/tags-visible $ hg tags tip 6:b968051b5cf3 @@ -372,7 +372,7 @@ $ chmod a+w .hg/cache/hgtagsfnodes1 #endif - $ rm -f .hg/cache/tags + $ rm -f .hg/cache/tags-visible $ hg tags tip 6:b968051b5cf3 bar 1:78391a272241 @@ -524,7 +524,7 @@ $ hg tags # partly stale tip 4:735c3ca72986 bar 0:bbd179dfa0a7 - $ rm -f .hg/cache/tags + $ rm -f .hg/cache/tags-visible $ hg tags # cold cache tip 4:735c3ca72986 bar 0:bbd179dfa0a7