# 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 -r 6efad1cc07de -r 9c6d0abdb94e mercurial/commands.py --- a/mercurial/commands.py Tue Nov 29 18:06:23 2005 +0100 +++ b/mercurial/commands.py Tue Nov 29 22:29:14 2005 +0100 @@ -2002,8 +2002,10 @@ 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 -r 6efad1cc07de -r 9c6d0abdb94e tests/test-tag --- a/tests/test-tag Tue Nov 29 18:06:23 2005 +0100 +++ b/tests/test-tag Tue Nov 29 22:29:14 2005 +0100 @@ -11,3 +11,7 @@ echo foo >> .hgtags hg tag -d "0 0" "bleah2" || echo "failed" +hg tag -l 'xx +newline' +hg tag -l 'xx:xx' +true diff -r 6efad1cc07de -r 9c6d0abdb94e tests/test-tag.out --- a/tests/test-tag.out Tue Nov 29 18:06:23 2005 +0100 +++ b/tests/test-tag.out Tue Nov 29 22:29:14 2005 +0100 @@ -18,3 +18,5 @@ 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