# HG changeset patch # User Kevin Bullock # Date 1350512619 18000 # Node ID 5023027240a191abab849e6941a7cc8c11816432 # Parent b17be267b59c6c3646bff7383a7cce5e7fb9cea1 bookmarks: use scmutil.checknewlabel Validation is pulled up into the commands module to avoid an import cycle. diff -r b17be267b59c -r 5023027240a1 mercurial/bookmarks.py --- a/mercurial/bookmarks.py Wed Oct 17 16:34:46 2012 -0500 +++ b/mercurial/bookmarks.py Wed Oct 17 17:23:39 2012 -0500 @@ -10,14 +10,6 @@ from mercurial import encoding, error, util, obsolete, phases import errno, os -def checkvalid(mark): - for c in (':', '\0', '\n', '\r'): - if c in mark: - raise util.Abort(_("bookmark '%s' contains illegal " - "character" % mark)) - if mark in ['tip', '.', 'null']: - raise util.Abort(_('the name \'%s\' is reserved') % mark) - def read(repo): '''Parse .hg/bookmarks file and return a dictionary @@ -81,8 +73,6 @@ if repo._bookmarkcurrent not in refs: setcurrent(repo, None) - for mark in refs.keys(): - checkvalid(mark) wlock = repo.wlock() try: @@ -113,7 +103,6 @@ if mark not in repo._bookmarks: mark = '' - checkvalid(mark) wlock = repo.wlock() try: diff -r b17be267b59c -r 5023027240a1 mercurial/commands.py --- a/mercurial/commands.py Wed Oct 17 16:34:46 2012 -0500 +++ b/mercurial/commands.py Wed Oct 17 17:23:39 2012 -0500 @@ -794,6 +794,11 @@ if not mark: raise util.Abort(_("bookmark names cannot consist entirely of " "whitespace")) + for c in (':', '\0', '\n', '\r'): + if c in mark: + raise util.Abort(_("bookmark '%s' contains illegal " + "character" % mark)) + scmutil.checknewlabel(repo, mark) return mark def checkconflict(repo, mark, force=False):