diff mercurial/scmutil.py @ 17821:361ab1e2086f

scmutil: add bad character checking to checknewlabel This factors out the checks from tags and bookmarks, and newly applies the same prohibitions to branches. checknewlabel takes a new parameter, kind, indicating the kind of label being checked. Test coverage is added for all three types of labels.
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 17 Oct 2012 21:42:06 -0500
parents b17be267b59c
children 408ded42c5ec
line wrap: on
line diff
--- a/mercurial/scmutil.py	Wed Oct 17 21:39:07 2012 -0500
+++ b/mercurial/scmutil.py	Wed Oct 17 21:42:06 2012 -0500
@@ -27,9 +27,13 @@
     else:
         ui.status(_("no changes found\n"))
 
-def checknewlabel(repo, lbl):
+def checknewlabel(repo, lbl, kind):
     if lbl in ['tip', '.', 'null']:
         raise util.Abort(_("the name '%s' is reserved") % lbl)
+    for c in (':', '\0', '\n', '\r'):
+        if c in lbl:
+            raise util.Abort(_("%r cannot be used in a %s name") %
+                               (c, kind))
 
 def checkfilename(f):
     '''Check that the filename f is an acceptable filename for a tracked file'''