Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/scmutil.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 | 9837cafc25b1 |
children | 361ab1e2086f |
comparison
equal
deleted
inserted
replaced
17816:19388ba75a06 | 17817:b17be267b59c |
---|---|
24 if secretlist: | 24 if secretlist: |
25 ui.status(_("no changes found (ignored %d secret changesets)\n") | 25 ui.status(_("no changes found (ignored %d secret changesets)\n") |
26 % len(secretlist)) | 26 % len(secretlist)) |
27 else: | 27 else: |
28 ui.status(_("no changes found\n")) | 28 ui.status(_("no changes found\n")) |
29 | |
30 def checknewlabel(repo, lbl): | |
31 if lbl in ['tip', '.', 'null']: | |
32 raise util.Abort(_("the name '%s' is reserved") % lbl) | |
29 | 33 |
30 def checkfilename(f): | 34 def checkfilename(f): |
31 '''Check that the filename f is an acceptable filename for a tracked file''' | 35 '''Check that the filename f is an acceptable filename for a tracked file''' |
32 if '\r' in f or '\n' in f: | 36 if '\r' in f or '\n' in f: |
33 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) | 37 raise util.Abort(_("'\\n' and '\\r' disallowed in filenames: %r") % f) |