[PATCH 1 of 2 STABLE] tags: update tag type only if tag node is updated (issue3911)

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


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1367280122 -32400
#      Tue Apr 30 09:02:02 2013 +0900
# Branch stable
# Node ID 3d22d2a9d641c727f10a0f23885fbc0a854f4f50
# Parent  f01a351db79106ba96ac6d527cf69944fd98e665
tags: update tag type only if tag node is updated (issue3911)

Before this patch, tag type information is always updated, even if tag
previously read in has higher priority than one newly read in.

This causes that the tag type is displayed as "local", even if global
tag overwrites existing local one successfully.

This patch updates tag type only if tag node is updated.

This patch tests overwriting local tags below:

  - visible one (normal case)
  - already removed one (recorded as null)

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -132,9 +132,10 @@
         if (bnode != anode and anode in bhist and
             (bnode not in ahist or len(bhist) > len(ahist))):
             anode = bnode
+        else:
+            tagtypes[name] = tagtype
         ahist.extend([n for n in bhist if n not in ahist])
         alltags[name] = anode, ahist
-        tagtypes[name] = tagtype
 
 
 # The tag cache only stores info about heads, not the tag contents
diff --git a/tests/test-tags.t b/tests/test-tags.t
--- a/tests/test-tags.t
+++ b/tests/test-tags.t
@@ -381,4 +381,26 @@
   localtag                           0:bbd179dfa0a7 local
   globaltag                          0:bbd179dfa0a7
 
+Test for issue3911
+
+  $ hg tag -r 0 -l localtag2
+  $ hg tag -l --remove localtag2
+  $ hg tags -v
+  tip                                1:a0b6fe111088
+  localtag                           0:bbd179dfa0a7 local
+  globaltag                          0:bbd179dfa0a7
+
+  $ hg tag -r 1 -f localtag
+  $ hg tags -v
+  tip                                2:5c70a037bb37
+  localtag                           1:a0b6fe111088
+  globaltag                          0:bbd179dfa0a7
+
+  $ hg tag -r 1 localtag2
+  $ hg tags -v
+  tip                                3:bbfb8cd42be2
+  localtag2                          1:a0b6fe111088
+  localtag                           1:a0b6fe111088
+  globaltag                          0:bbd179dfa0a7
+
   $ cd ..


More information about the Mercurial-devel mailing list