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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 30, 2013, 12:57 a.m.
Message ID <3d22d2a9d641c727f10a.1367283449@feefifofum>
Download mbox | patch
Permalink /patch/1507/
State Accepted
Commit cb95716da5fe37a9bd6a8c7da73dc6caf89d5fe7
Headers show

Comments

Katsunori FUJIWARA - April 30, 2013, 12:57 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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)

Patch

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 ..