# HG changeset patch # User Benoit Boissinot # Date 1133299754 -3600 # Node ID 9c6d0abdb94e102b640608cf2e33b03757c78bfc # Parent 6efad1cc07de3f123a37e877bd4cef31f994f074 disallow '\n' and '\r' in tag names add a test for disallowed characters in tag names diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2002,8 +2002,10 @@ def tag(ui, repo, name, rev=None, **opts else: r = hex(repo.changelog.tip()) - if name.find(revrangesep) >= 0: - raise util.Abort(_("'%s' cannot be used in a tag name") % revrangesep) + disallowed = (revrangesep, '\r', '\n') + for c in disallowed: + if name.find(c) >= 0: + raise util.Abort(_("%s cannot be used in a tag name") % repr(c)) if opts['local']: repo.opener("localtags", "a").write("%s %s\n" % (r, name)) diff --git a/tests/test-tag b/tests/test-tag --- a/tests/test-tag +++ b/tests/test-tag @@ -11,3 +11,7 @@ hg history echo foo >> .hgtags hg tag -d "0 0" "bleah2" || echo "failed" +hg tag -l 'xx +newline' +hg tag -l 'xx:xx' +true diff --git a/tests/test-tag.out b/tests/test-tag.out --- a/tests/test-tag.out +++ b/tests/test-tag.out @@ -18,3 +18,5 @@ summary: test abort: working copy of .hgtags is changed (please commit .hgtags manually) failed +abort: '\n' cannot be used in a tag name +abort: ':' cannot be used in a tag name