Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.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 | 5023027240a1 |
children | c284085d17a8 |
comparison
equal
deleted
inserted
replaced
17820:c547e1acc37c | 17821:361ab1e2086f |
---|---|
792 def checkformat(mark): | 792 def checkformat(mark): |
793 mark = mark.strip() | 793 mark = mark.strip() |
794 if not mark: | 794 if not mark: |
795 raise util.Abort(_("bookmark names cannot consist entirely of " | 795 raise util.Abort(_("bookmark names cannot consist entirely of " |
796 "whitespace")) | 796 "whitespace")) |
797 for c in (':', '\0', '\n', '\r'): | 797 scmutil.checknewlabel(repo, mark, 'bookmark') |
798 if c in mark: | |
799 raise util.Abort(_("bookmark '%s' contains illegal " | |
800 "character" % mark)) | |
801 scmutil.checknewlabel(repo, mark) | |
802 return mark | 798 return mark |
803 | 799 |
804 def checkconflict(repo, mark, force=False): | 800 def checkconflict(repo, mark, force=False): |
805 if mark in marks and not force: | 801 if mark in marks and not force: |
806 raise util.Abort(_("bookmark '%s' already exists " | 802 raise util.Abort(_("bookmark '%s' already exists " |
5643 rev_ = "." | 5639 rev_ = "." |
5644 names = [t.strip() for t in (name1,) + names] | 5640 names = [t.strip() for t in (name1,) + names] |
5645 if len(names) != len(set(names)): | 5641 if len(names) != len(set(names)): |
5646 raise util.Abort(_('tag names must be unique')) | 5642 raise util.Abort(_('tag names must be unique')) |
5647 for n in names: | 5643 for n in names: |
5648 scmutil.checknewlabel(repo, n) | 5644 scmutil.checknewlabel(repo, n, 'tag') |
5649 if not n: | 5645 if not n: |
5650 raise util.Abort(_('tag names cannot consist entirely of ' | 5646 raise util.Abort(_('tag names cannot consist entirely of ' |
5651 'whitespace')) | 5647 'whitespace')) |
5652 if opts.get('rev') and opts.get('remove'): | 5648 if opts.get('rev') and opts.get('remove'): |
5653 raise util.Abort(_("--rev and --remove are incompatible")) | 5649 raise util.Abort(_("--rev and --remove are incompatible")) |