comparison mercurial/localrepo.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 c547e1acc37c
children 0c1185f6ddd7
comparison
equal deleted inserted replaced
17820:c547e1acc37c 17821:361ab1e2086f
383 return 'file:' + self.root 383 return 'file:' + self.root
384 384
385 def hook(self, name, throw=False, **args): 385 def hook(self, name, throw=False, **args):
386 return hook.hook(self.ui, self, name, throw, **args) 386 return hook.hook(self.ui, self, name, throw, **args)
387 387
388 tag_disallowed = ':\0\r\n'
389
390 def _tag(self, names, node, message, local, user, date, extra={}): 388 def _tag(self, names, node, message, local, user, date, extra={}):
391 if isinstance(names, str): 389 if isinstance(names, str):
392 allchars = names
393 names = (names,) 390 names = (names,)
394 else:
395 allchars = ''.join(names)
396 for c in self.tag_disallowed:
397 if c in allchars:
398 raise util.Abort(_('%r cannot be used in a tag name') % c)
399 391
400 branches = self.branchmap() 392 branches = self.branchmap()
401 for name in names: 393 for name in names:
402 self.hook('pretag', throw=True, node=hex(node), tag=name, 394 self.hook('pretag', throw=True, node=hex(node), tag=name,
403 local=local) 395 local=local)