# HG changeset patch # User Nicolas Dumazet # Date 1271666472 -32400 # Node ID eb23c876c111864572b2a30c634b1126c7468973 # Parent a2a6fd1064df7f23a0b40c17711326094139bc2c tag: warn users about tag/branch possible name conflicts As reported recently, Mercurial users can easily find confusion when using a common name for a tag and a branch. It seems reasonable to warn them about this potential outcome, to avoid that "surprise". * Explain briefly the issue in "hg help tag" * Warn when tagging a revision diff -r a2a6fd1064df -r eb23c876c111 mercurial/commands.py --- a/mercurial/commands.py Mon Apr 19 11:31:19 2010 +0200 +++ b/mercurial/commands.py Mon Apr 19 17:41:12 2010 +0900 @@ -3209,6 +3209,9 @@ shared among repositories). See :hg:`help dates` for a list of formats valid for -d/--date. + + Since tag names have priority over branch names during revision + lookup, using an existing branch name as a tag name is discouraged. """ rev_ = "." diff -r a2a6fd1064df -r eb23c876c111 mercurial/localrepo.py --- a/mercurial/localrepo.py Mon Apr 19 11:31:19 2010 +0200 +++ b/mercurial/localrepo.py Mon Apr 19 17:41:12 2010 +0900 @@ -164,9 +164,13 @@ if c in allchars: raise util.Abort(_('%r cannot be used in a tag name') % c) + branches = self.branchmap() for name in names: self.hook('pretag', throw=True, node=hex(node), tag=name, local=local) + if name in branches: + self.ui.warn(_("warning: tag %s conflicts with existing" + " branch name\n") % name) def writetags(fp, names, munge, prevtags): fp.seek(0, 2) diff -r a2a6fd1064df -r eb23c876c111 tests/test-tag --- a/tests/test-tag Mon Apr 19 11:31:19 2010 +0200 +++ b/tests/test-tag Mon Apr 19 17:41:12 2010 +0900 @@ -68,3 +68,8 @@ cat .hgtags hg tag -d '1000000 0' newline cat .hgtags + +echo % tag and branch using same name +hg branch tag-and-branch-same-name +hg ci -m"discouraged" +hg tag tag-and-branch-same-name diff -r a2a6fd1064df -r eb23c876c111 tests/test-tag.out --- a/tests/test-tag.out Mon Apr 19 11:31:19 2010 +0200 +++ b/tests/test-tag.out Mon Apr 19 17:41:12 2010 +0900 @@ -94,3 +94,6 @@ f68b039e72eacbb2e68b0543e1f6e50990aa2bb5 localnewline 0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar0acdaf8983679e0aac16e811534eb49d7ee1f2b4 foobar 6ae703d793c8b1f097116869275ecd97b2977a2b newline +% tag and branch using same name +marked working directory as branch tag-and-branch-same-name +warning: tag tag-and-branch-same-name conflicts with existing branch name