2 bugs in tag removal

Matt Mackall mpm at selenic.com
Sat Dec 8 00:15:17 CST 2007


On Sat, Dec 08, 2007 at 02:28:51PM +0900, Osku Salerma wrote:
> 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
> not.
> 
> 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

Interesting. I would have expected tags would then hide 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

That actually 'works'. We've locally 'hidden' the global tag. I'm
tempted to say that that's useful behavior. Hiding a local tag by
checking in a global one though: not so much.

> 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.

How about a parallel dict that tracks the source of each tag?

-- 
Mathematics is the supreme nostalgia of our time.


More information about the Mercurial-devel mailing list