comparison mercurial/commands.py @ 17817:b17be267b59c

scmutil: add function to validate new branch, tag, and bookmark names For now the new function only checks to make sure the new label name isn't a reserved name ('tip', '.', or 'null'). Eventually more of the checks will be unified between the different types of labels. The `tag` command is trivially updated to use it. Updating branches and bookmarks to use it is slightly more invasive and thus reserved for later patches.
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 17 Oct 2012 16:34:46 -0500
parents f88ca484c3e9
children 5023027240a1
comparison
equal deleted inserted replaced
17816:19388ba75a06 17817:b17be267b59c
5638 rev_ = "." 5638 rev_ = "."
5639 names = [t.strip() for t in (name1,) + names] 5639 names = [t.strip() for t in (name1,) + names]
5640 if len(names) != len(set(names)): 5640 if len(names) != len(set(names)):
5641 raise util.Abort(_('tag names must be unique')) 5641 raise util.Abort(_('tag names must be unique'))
5642 for n in names: 5642 for n in names:
5643 if n in ['tip', '.', 'null']: 5643 scmutil.checknewlabel(repo, n)
5644 raise util.Abort(_("the name '%s' is reserved") % n)
5645 if not n: 5644 if not n:
5646 raise util.Abort(_('tag names cannot consist entirely of ' 5645 raise util.Abort(_('tag names cannot consist entirely of '
5647 'whitespace')) 5646 'whitespace'))
5648 if opts.get('rev') and opts.get('remove'): 5647 if opts.get('rev') and opts.get('remove'):
5649 raise util.Abort(_("--rev and --remove are incompatible")) 5648 raise util.Abort(_("--rev and --remove are incompatible"))