2 bugs in tag removal

Osku Salerma osku at iki.fi
Fri Dec 7 23:28:51 CST 2007

Tag removal is buggy because it doesn't distinguish between local/global
tags while checking whether the tag the user wants to remove exists or

To reproduce the bug:

hg init t
cd t
touch foo
hg add foo
hg ci -m 'add foo'

hg tag -r 0 -l localtag

# this should fail since the global tag "localtag" doesn't exist, instead
# it writes a tag-removal line to .hgtags and commits that
hg tag --remove localtag

hg tag -r 0 globaltag

# mirror image of the above, this time the tag-deletion is written to
# .hg/localtags even though it has no tag "globaltag"
hg tag --remove -l globaltag

The offending code in commands.py:

     if opts['remove']:
         if not name in repo.tags():
             raise util.Abort(_('tag %s does not exist') % name)

I took a look at fixing this, but it would require being able to
distinguish between local/global tags after they have been combined into
the tagscache, or alternatively keeping two separate caches and adding
getlocaltags and getglobaltags functions.

If you let me know which of the above approaches you'd prefer to fixing
this, or some alternative way you come up with, I can implement it.

Osku Salerma

More information about the Mercurial-devel mailing list