tags: fix abababa case, with test case
authorMatt Mackall <mpm@selenic.com>
Thu, 22 Mar 2007 23:52:50 -0500
changeset 4266 fe7f38dda34b
parent 4247 89075f106414
child 4267 8185a1ca8628
tags: fix abababa case, with test case
mercurial/localrepo.py
tests/test-tags
tests/test-tags.out
--- a/mercurial/localrepo.py	Mon Mar 19 19:07:40 2007 -0300
+++ b/mercurial/localrepo.py	Thu Mar 22 23:52:50 2007 -0500
@@ -288,10 +288,10 @@
                     warn(_("tag '%s' refers to unknown node") % key)
                     continue
 
-                h = {}
+                h = []
                 if key in filetags:
                     n, h = filetags[key]
-                    h[n] = True
+                    h.append(n)
                 filetags[key] = (bin_n, h)
 
             for k,nh in filetags.items():
@@ -307,7 +307,7 @@
                 if bn != an and an in bh and \
                    (bn not in ah or len(bh) > len(ah)):
                     an = bn
-                ah.update(bh)
+                ah.append([n for n in bh if n not in ah])
                 globaltags[k] = an, ah
 
         # read the tags file from each head, ending with the tip
--- a/tests/test-tags	Mon Mar 19 19:07:40 2007 -0300
+++ b/tests/test-tags	Thu Mar 22 23:52:50 2007 -0500
@@ -80,6 +80,25 @@
 hg ci -m 'change foo 2' -d '1000000 0' # rev 4
 hg tags
 
+# test tag removal
 hg tag --remove -d '1000000 0' bar 
 hg tip
 hg tags
+
+# test tag rank
+cd ..
+hg init t3
+cd t3
+echo foo > foo
+hg add foo
+hg ci -m 'add foo' -d '1000000 0'      # rev 0
+hg tag -d '1000000 0' bar              # rev 1 bar -> 0
+hg tag -d '1000000 0' bar              # rev 2 bar -> 1
+hg tag -d '1000000 0' -r 0 bar         # rev 3 bar -> 0
+hg tag -d '1000000 0' -r 1 bar         # rev 3 bar -> 1
+hg tag -d '1000000 0' -r 0 bar         # rev 4 bar -> 0
+hg tags
+hg co 3
+echo barbar > foo
+hg ci -m 'change foo' -d '1000000 0'      # rev 0
+hg tags
--- a/tests/test-tags.out	Mon Mar 19 19:07:40 2007 -0300
+++ b/tests/test-tags.out	Thu Mar 22 23:52:50 2007 -0500
@@ -49,3 +49,8 @@
 summary:     Removed tag bar
 
 tip                                5:57e1983b4a60
+tip                                5:d8bb4d1eff25
+bar                                0:b409d9da318e
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+tip                                6:b5ff9d142648
+bar                                0:b409d9da318e