[PATCH 2 of 3 V2] move tags.cache and branchheads.cache to a collected cache folder .hg/caches/

Jason Harris jason.f.harris at gmail.com
Sat Jan 1 23:03:10 CST 2011


# HG changeset patch
# User jfh <jason at jasonfharris.com>
# Date 1293937052 -3600
# Node ID d47017e900275807a63b8f653f714c43593d959f
# Parent  4d97c3e51f4f05f4f93d646b2d0ac16120f82892
move tags.cache and branchheads.cache to a collected cache folder .hg/caches/

The generation of cache files like tags.cache and branchheads.cache is not an
actual reflection of things changing in the whole of the .hg directory (like eg
a commit or a rebase or something) but instead these cache files are just part
of bookkeeping. As such its convenient to allow various clients to ignore file
events to do with these cache files which would otherwise cause a double
refresh. Eg one refresh might occur after a commit, but the act of refreshing
after the commit would cause Mercurial to generate a new branchheads.cache which
would then cause a second refresh, for clients.

However if these cache files are moved into a directory like eg .hg/caches/ then
GUI clients on OSX (and possibly other platforms) can happily ignore file events
in this cache directory.

Part II update tests.

diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -182,7 +182,8 @@
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   2 r4/.hg/branch
-  2 r4/.hg/branchheads.cache
+  2 r4/.hg/caches/branchheads.cache
+  2 r4/.hg/caches/tags.cache
   2 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
@@ -194,7 +195,6 @@
   2 r4/.hg/store/data/f1.i
   2 r4/.hg/store/fncache
   2 r4/.hg/store/undo
-  2 r4/.hg/tags.cache
   2 r4/.hg/undo.branch
   2 r4/.hg/undo.desc
   2 r4/.hg/undo.dirstate
@@ -210,7 +210,8 @@
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   1 r4/.hg/branch
-  2 r4/.hg/branchheads.cache
+  2 r4/.hg/caches/branchheads.cache
+  2 r4/.hg/caches/tags.cache
   1 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
@@ -222,7 +223,6 @@
   2 r4/.hg/store/data/f1.i
   2 r4/.hg/store/fncache
   2 r4/.hg/store/undo
-  2 r4/.hg/tags.cache
   2 r4/.hg/undo.branch
   2 r4/.hg/undo.desc
   2 r4/.hg/undo.dirstate
diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t
--- a/tests/test-inherit-mode.t
+++ b/tests/test-inherit-mode.t
@@ -105,7 +105,8 @@
   $ python ../printmodes.py ../push
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
-  00660 ../push/.hg/branchheads.cache
+  00770 ../push/.hg/caches/
+  00660 ../push/.hg/caches/branchheads.cache
   00660 ../push/.hg/requires
   00770 ../push/.hg/store/
   00660 ../push/.hg/store/00changelog.i
diff --git a/tests/test-mq-caches.t b/tests/test-mq-caches.t
--- a/tests/test-mq-caches.t
+++ b/tests/test-mq-caches.t
@@ -1,4 +1,4 @@
-  $ branches=.hg/branchheads.cache
+  $ branches=.hg/caches/branchheads.cache
   $ echo '[extensions]' >> $HGRCPATH
   $ echo 'mq =' >> $HGRCPATH
 
diff --git a/tests/test-mq.t b/tests/test-mq.t
--- a/tests/test-mq.t
+++ b/tests/test-mq.t
@@ -284,12 +284,12 @@
 qpush with dump of tag cache
 Dump the tag cache to ensure that it has exactly one head after qpush.
 
-  $ rm -f .hg/tags.cache
+  $ rm -f .hg/caches/tags.cache
   $ hg tags > /dev/null
 
-.hg/tags.cache (pre qpush):
+.hg/caches/tags.cache (pre qpush):
 
-  $ cat .hg/tags.cache
+  $ cat .hg/caches/tags.cache
   1 [\da-f]{40} (re)
   
   $ hg qpush
@@ -297,9 +297,9 @@
   now at: test.patch
   $ hg tags > /dev/null
 
-.hg/tags.cache (post qpush):
+.hg/caches/tags.cache (post qpush):
 
-  $ cat .hg/tags.cache
+  $ cat .hg/caches/tags.cache
   2 [\da-f]{40} (re)
   
   $ checkundo qpush
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -1,4 +1,4 @@
-  $ branchcache=.hg/branchheads.cache
+  $ branchcache=.hg/caches/branchheads.cache
 
   $ hg init t
   $ cd t
diff --git a/tests/test-static-http.t b/tests/test-static-http.t
--- a/tests/test-static-http.t
+++ b/tests/test-static-http.t
@@ -61,7 +61,7 @@
 
 check for HTTP opener failures when cachefile does not exist
 
-  $ rm .hg/*.cache
+  $ rm .hg/caches/*.cache
   $ cd ../local
   $ echo '[hooks]' >> .hg/hgrc
   $ echo 'changegroup = python ../printenv.py changegroup' >> .hg/hgrc
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -1,7 +1,7 @@
 Helper functions:
 
   $ cacheexists() {
-  >   [ -f .hg/tags.cache ] && echo "tag cache exists" || echo "no tag cache"
+  >   [ -f .hg/caches/tags.cache ] && echo "tag cache exists" || echo "no tag cache"
   > }
 
   $ dumptags() {
@@ -36,9 +36,9 @@
 
 Try corrupting the cache
 
-  $ printf 'a b' > .hg/tags.cache
+  $ printf 'a b' > .hg/caches/tags.cache
   $ hg identify
-  .hg/tags.cache is corrupt, rebuilding it
+  .hg/caches/tags.cache is corrupt, rebuilding it
   acb14030fe0a tip
   $ cacheexists
   tag cache exists
@@ -69,13 +69,13 @@
 
 Repeat with cold tag cache:
 
-  $ rm -f .hg/tags.cache
+  $ rm -f .hg/caches/tags.cache
   $ hg identify
   b9154636be93 tip
 
 And again, but now unable to write tag cache:
 
-  $ rm -f .hg/tags.cache
+  $ rm -f .hg/caches/tags.cache
   $ chmod 555 .hg
   $ hg identify
   b9154636be93 tip
@@ -216,7 +216,7 @@
 
 Dump cache:
 
-  $ cat .hg/tags.cache
+  $ cat .hg/caches/tags.cache
   4 0c192d7d5e6b78a714de54a2e9627952a877e25a 0c04f2a8af31de17fab7422878ee5a2dadbc943d
   3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0
   2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d
@@ -325,7 +325,7 @@
   $ hg tags                  # partly stale
   tip                                4:735c3ca72986
   bar                                0:bbd179dfa0a7
-  $ rm -f .hg/tags.cache
+  $ rm -f .hg/caches/tags.cache
   $ hg tags                  # cold cache
   tip                                4:735c3ca72986
   bar                                0:bbd179dfa0a7


More information about the Mercurial-devel mailing list