Mercurial > hg-stable
changeset 17815:be1467342038
bookmarks: abort directly on invalid name
This consolidates the abort message for a bookmark name containing
invalid characters into one place, and renames the valid() method to
checkvalid() to reflect the fact that it's no longer a predicate.
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Wed, 17 Oct 2012 17:03:01 -0500 |
parents | f88ca484c3e9 |
children | 19388ba75a06 |
files | mercurial/bookmarks.py |
diffstat | 1 files changed, 5 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Wed Oct 17 16:23:42 2012 -0500 +++ b/mercurial/bookmarks.py Wed Oct 17 17:03:01 2012 -0500 @@ -10,11 +10,11 @@ from mercurial import encoding, error, util, obsolete, phases import errno, os -def valid(mark): +def checkvalid(mark): for c in (':', '\0', '\n', '\r'): if c in mark: - return False - return True + raise util.Abort(_("bookmark '%s' contains illegal " + "character" % mark)) def read(repo): '''Parse .hg/bookmarks file and return a dictionary @@ -80,9 +80,7 @@ if repo._bookmarkcurrent not in refs: setcurrent(repo, None) for mark in refs.keys(): - if not valid(mark): - raise util.Abort(_("bookmark '%s' contains illegal " - "character" % mark)) + checkvalid(mark) wlock = repo.wlock() try: @@ -113,9 +111,7 @@ if mark not in repo._bookmarks: mark = '' - if not valid(mark): - raise util.Abort(_("bookmark '%s' contains illegal " - "character" % mark)) + checkvalid(mark) wlock = repo.wlock() try: