changeset 4213:3be4785f8994

tags: add --remove
author Matt Mackall <mpm@selenic.com>
date Wed, 14 Mar 2007 19:13:04 -0500
parents 6c0be67c2b27
children 5ccbc0be6cdb 90bb1ab53a85 ea976f5f3fa3
files mercurial/commands.py mercurial/localrepo.py tests/test-tags tests/test-tags.out
diffstat 4 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Mar 14 18:49:10 2007 -0500
+++ b/mercurial/commands.py	Wed Mar 14 19:13:04 2007 -0500
@@ -2439,14 +2439,20 @@
                   "please use 'hg tag [-r REV] NAME' instead\n"))
         if opts['rev']:
             raise util.Abort(_("use only one form to specify the revision"))
+    if opts['rev'] and opts['remove']:
+        raise util.Abort(_("--rev and --remove are incompatible"))
     if opts['rev']:
         rev_ = opts['rev']
+    message = opts['message']
+    if opts['remove']:
+        rev_ = nullid
+        if not message:
+            message = _('Removed tag %s') % name
     if not rev_ and repo.dirstate.parents()[1] != nullid:
         raise util.Abort(_('uncommitted merge - please provide a '
                            'specific revision'))
     r = repo.changectx(rev_).node()
 
-    message = opts['message']
     if not message:
         message = _('Added tag %s for changeset %s') % (name, short(r))
 
@@ -2935,7 +2941,8 @@
           ('m', 'message', '', _('message for tag commit log entry')),
           ('d', 'date', '', _('record datecode as commit date')),
           ('u', 'user', '', _('record user as commiter')),
-          ('r', 'rev', '', _('revision to tag'))],
+          ('r', 'rev', '', _('revision to tag')),
+          ('', 'remove', None, _('remove a tag'))],
          _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
     "tags": (tags, [], _('hg tags')),
     "tip":
--- a/mercurial/localrepo.py	Wed Mar 14 18:49:10 2007 -0500
+++ b/mercurial/localrepo.py	Wed Mar 14 19:13:04 2007 -0500
@@ -328,7 +328,8 @@
         self.tagscache = {}
         for k,nh in globaltags.items():
             n = nh[0]
-            self.tagscache[k] = n
+            if n != nullid:
+                self.tagscache[k] = n
         self.tagscache['tip'] = self.changelog.tip()
 
         return self.tagscache
--- a/tests/test-tags	Wed Mar 14 18:49:10 2007 -0500
+++ b/tests/test-tags	Wed Mar 14 19:13:04 2007 -0500
@@ -79,3 +79,7 @@
 echo >> foo
 hg ci -m 'change foo 2' -d '1000000 0' # rev 4
 hg tags
+
+hg tag --remove -d '1000000 0' bar 
+hg tip
+hg tags
--- a/tests/test-tags.out	Wed Mar 14 18:49:10 2007 -0500
+++ b/tests/test-tags.out	Wed Mar 14 19:13:04 2007 -0500
@@ -42,3 +42,10 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 tip                                4:36195b728445
 bar                                1:b204a97e6e8d
+changeset:   5:57e1983b4a60
+tag:         tip
+user:        test
+date:        Mon Jan 12 13:46:40 1970 +0000
+summary:     Removed tag bar
+
+tip                                5:57e1983b4a60