Patchwork [4,of,5] tags: write a separate tags cache file for unfiltered repos

login
register
mail settings
Submitter Gregory Szorc
Date April 16, 2015, 4:02 p.m.
Message ID <73090097c95a850b7af5.1429200127@gps-mbp.local>
Download mbox | patch
Permalink /patch/8715/
State Superseded
Commit 1062663808ce45610b766af650717926f253be4b
Headers show

Comments

Gregory Szorc - April 16, 2015, 4:02 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1429199653 14400
#      Thu Apr 16 11:54:13 2015 -0400
# Node ID 73090097c95a850b7af5584904288dea61e3b38a
# Parent  ae6e9a2d4e3bed28324ba8987dda3b91fdaf949c
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.
Pierre-Yves David - April 16, 2015, 7:15 p.m.
On 04/16/2015 12:02 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1429199653 14400
> #      Thu Apr 16 11:54:13 2015 -0400
> # Node ID 73090097c95a850b7af5584904288dea61e3b38a
> # Parent  ae6e9a2d4e3bed28324ba8987dda3b91fdaf949c
> 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.

We are introducing a new file format I think it should be called "tags2" 
and keep the unfiltered version without prefix to match what branchmap 
is doing.

I also fixed it locally after Greg approval. And pushed the result to 
the clowncopter.

Patch

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -35,12 +35,13 @@  import time
 # manifest for each head. This can take dozens or over 100ms for
 # 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:
 #
 #   <tiprev> <tipnode> [<filteredhash>]
@@ -238,12 +239,9 @@  def _updatetags(filetags, tagtype, allta
         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
+    return 'cache/tags-%s' % (repo.filtername or 'unfiltered')
 
 def _readtagcache(ui, repo):
     '''Read the tag cache.
 
diff --git a/tests/test-obsolete-tag-cache.t b/tests/test-obsolete-tag-cache.t
--- a/tests/test-obsolete-tag-cache.t
+++ b/tests/test-obsolete-tag-cache.t
@@ -90,4 +90,24 @@  Hiding another changeset should cause th
   1970/01/01 00:00:00 bob> tags
   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/tags-unfiltered
+  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)