How can one change the name of a tag?
Asked Answered
C

5

17

I have made a tag in mercurial:

hg tag release_123

Later on I found out that the name was wrong, it should be release_124. Is it possible to simply rename the tag or do I have to create a new one?

Centrosymmetric answered 27/9, 2011 at 11:56 Comment(0)
C
20

I would do it by removing the tag and then adding a new tag with the new name

The Mercurial tag wiki explains how to remove a tag:

How do I remove a tag?

Either by

  • hg tag --remove tagname

(this being the nearest equivalent to cvs tag -d)

  • adding tagname 0000000000000000000000000000000000000000 to the end of .hgtags

  • removing all references to tagname in .hgtags (but this might confuse the multiple-head tag collision resolution algorithm)

Clientele answered 27/9, 2011 at 12:19 Comment(2)
Is there any reason at all not to use the first one?Blondell
@AndyThomas not that I know of.Clientele
E
9

You should be able to edit regular tags in the .hgtags file (and commit it)

A "regular" tag (with no special specifier) is revision controlled, does propagate with other changes, and lives in the .hgtags file in a repository.

This old thread mentions you need to do this in all HEADS of a repo though.

Eboh answered 27/9, 2011 at 12:2 Comment(1)
Great, very easy solution.Dillondillow
C
1

Like what @matt-ellen has said, but in reverse. Because I like to be sure the revision is tagged properly before I delete the old tag.

Here I create an example of a repo with 4 revisions.

  1. View the log
  2. View the tags (none, and tip)
  3. Create a tag at revision #2 (using the hash)
  4. View tags (now there is one, and tip)
  5. Create new tag name
  6. View tags (now there are two, and tip)
  7. Remove bad tag name
  8. View tags (now there is one, and tip)

Example:

$ hg log

changeset:   3:271cb2836c23
user:        user <[email protected]>
date:        Sat Mar 01 13:49:55 2014 -0600
summary:     Very important things.

changeset:   2:3c953ee62faf
user:        user <[email protected]>
date:        Wed Feb 26 00:17:55 2014 -0600
summary:     Did some changes.

changeset:   1:54e2275eed1e
user:        user <[email protected]>
date:        Tue Feb 25 01:34:31 2014 -0600
summary:     So, lots of things here.

changeset:   0:3f3e1aee4e14
user:        user <[email protected]>
date:        Sat Feb 22 00:42:29 2014 -0600
summary:     Inital project checkin.

$ hg tags
tip          3:271cb2836c23

$ hg tag -r 3c953ee62faf release_123
$ hg tags
tip           3:271cb2836c23
release_123   2:3c953ee62faf

$ hg tag -r 3c953ee62faf release_124
$ hg tags
tip           3:271cb2836c23
release_123   2:3c953ee62faf
release_124   2:3c953ee62faf

$ hg tag --remove release_123
$ hg tags
tip           3:271cb2836c23
release_124   2:3c953ee62faf
Casualty answered 8/6, 2014 at 2:42 Comment(0)
L
1

I've been looking for a solution to same issue: I found this command which creates another tag with copied from the previous one with a new name. But it does not remove the old one. It has to be deleted manually.

Rename a tag :

hg tag -f -r

To delete the old tag:

hg tag --remove

Lining answered 26/8, 2014 at 11:28 Comment(0)
S
1

If you are using TortoiseHg, its pretty simple:

case#1 if it's a local tag: right click a tagged change-set|tag...|Select tag |Options |Replace existing tag | Done < local tag will disappear>

case#2 if its global tag: right click a tagged change-set|tag...| Select tag| Options | Replace existing tag | Remove Now select change-set and create new tag (its like a renamed tag). Not in one click though :-)

Slowmoving answered 20/11, 2019 at 1:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.