changeset 4268:f38f90a177dc

Merge with -stable
author Matt Mackall <mpm@selenic.com>
date Sat, 24 Mar 2007 02:45:08 -0500
parents 94bb953b43e5 (current diff) 8185a1ca8628 (diff)
children 73c918c71300
files mercurial/commands.py mercurial/localrepo.py
diffstat 4 files changed, 39 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Mar 23 01:04:21 2007 -0500
+++ b/mercurial/commands.py	Sat Mar 24 02:45:08 2007 -0500
@@ -2499,6 +2499,9 @@
         rev_ = nullid
         if not message:
             message = _('Removed tag %s') % name
+    elif name in repo.tags() and not opts['force']:
+        raise util.Abort(_('a tag named %s already exists (use -f to force)')
+                         % name)
     if not rev_ and repo.dirstate.parents()[1] != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
@@ -2962,7 +2965,8 @@
          _('hg status [OPTION]... [FILE]...')),
     "tag":
         (tag,
-         [('l', 'local', None, _('make the tag local')),
+         [('f', 'force', None, _('replace existing tag')),
+          ('l', 'local', None, _('make the tag local')),
           ('m', 'message', '', _('message for tag commit log entry')),
           ('d', 'date', '', _('record datecode as commit date')),
           ('u', 'user', '', _('record user as commiter')),
--- a/mercurial/localrepo.py	Fri Mar 23 01:04:21 2007 -0500
+++ b/mercurial/localrepo.py	Sat Mar 24 02:45:08 2007 -0500
@@ -289,10 +289,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():
@@ -308,7 +308,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	Fri Mar 23 01:04:21 2007 -0500
+++ b/tests/test-tags	Sat Mar 24 02:45:08 2007 -0500
@@ -74,12 +74,34 @@
 echo >> foo
 hg ci -m 'change foo 1' -d '1000000 0' # rev 2
 hg up -C 1
-hg tag -r 1 -d '1000000 0' bar         # rev 3
+hg tag -r 1 -d '1000000 0' -f bar      # rev 3
 hg up -C 1
 echo >> foo
 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' -f bar            # rev 1 bar -> 0
+hg tag -d '1000000 0' -f bar            # rev 2 bar -> 1
+hg tag -d '1000000 0' -fr 0 bar         # rev 3 bar -> 0
+hg tag -d '1000000 0' -fr 1 bar         # rev 3 bar -> 1
+hg tag -d '1000000 0' -fr 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
+
+hg tag -d '1000000 0' -r 3 bar         # should complain
+hg tags
\ No newline at end of file
--- a/tests/test-tags.out	Fri Mar 23 01:04:21 2007 -0500
+++ b/tests/test-tags.out	Sat Mar 24 02:45:08 2007 -0500
@@ -49,3 +49,11 @@
 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
+abort: a tag named bar already exists (use -f to force)
+tip                                6:b5ff9d142648
+bar                                0:b409d9da318e