[PATCH 2 of 2 STABLE] tags: write tag overwriting history also into tag cache file (issue3911)

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Apr 29 19:57:30 CDT 2013


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1367282629 -32400
#      Tue Apr 30 09:43:49 2013 +0900
# Branch stable
# Node ID 68c39c5118044915b3472670d0b5261a77325f6c
# Parent  3d22d2a9d641c727f10a0f23885fbc0a854f4f50
tags: write tag overwriting history also into tag cache file (issue3911)

Before this patch, tag overwriting history is not written into tag
cache file ".hg/cache/tags".

This may give higher priority to local tag than global one, even if
the former is overwritten by the latter, because tag overwriting
history is used to compare priorities of them (as "rank").

In such cases, "hg tags" invocations using tag cache file shows
incorrect tag information.

This patch writes tag overwriting history also into tag cache file.

As far as I confirmed, the revision 5ccdca7df211, which switched tag
cache file from ".hg/tags.cache" to ".hg/cache/tags", already uses
"_readtagcache()" implemented almost as same as current one.

It seems to work correctly, even if tag cache file contains tag
overwriting history, from the point of view for backward
compatibility.

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -30,9 +30,6 @@
     (heads, tagfnode, cachetags, shouldwrite) = _readtagcache(ui, repo)
     if cachetags is not None:
         assert not shouldwrite
-        # XXX is this really 100% correct?  are there oddball special
-        # cases where a global tag should outrank a local tag but won't,
-        # because cachetags does not contain rank info?
         _updatetags(cachetags, 'global', alltags, tagtypes)
         return
 
@@ -290,6 +287,8 @@
     # the cache.
     cachefile.write('\n')
     for (name, (node, hist)) in cachetags.iteritems():
+        for n in hist:
+            cachefile.write("%s %s\n" % (hex(n), name))
         cachefile.write("%s %s\n" % (hex(node), name))
 
     try:
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -221,6 +221,8 @@
   3 6fa450212aeb2a21ed616a54aea39a4a27894cd7 7d3b718c964ef37b89e550ebdafd5789e76ce1b0
   2 7a94127795a33c10a370c93f731fd9fea0b79af6 0c04f2a8af31de17fab7422878ee5a2dadbc943d
   
+  bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
+  bbd179dfa0a71671c253b3ae0aa1513b60d199fa bar
   78391a272241d70354aa14c874552cad6b51bb42 bar
 
 Test tag removal:
@@ -396,6 +398,11 @@
   localtag                           1:a0b6fe111088
   globaltag                          0:bbd179dfa0a7
 
+  $ hg tags -v
+  tip                                2:5c70a037bb37
+  localtag                           1:a0b6fe111088
+  globaltag                          0:bbd179dfa0a7
+
   $ hg tag -r 1 localtag2
   $ hg tags -v
   tip                                3:bbfb8cd42be2
@@ -403,4 +410,10 @@
   localtag                           1:a0b6fe111088
   globaltag                          0:bbd179dfa0a7
 
+  $ hg tags -v
+  tip                                3:bbfb8cd42be2
+  localtag2                          1:a0b6fe111088
+  localtag                           1:a0b6fe111088
+  globaltag                          0:bbd179dfa0a7
+
   $ cd ..


More information about the Mercurial-devel mailing list