##// END OF EJS Templates
bookmarks: abort directly on invalid name...
Kevin Bullock -
r17815:be146734 default
parent child Browse files
Show More
@@ -10,11 +10,11 b' from mercurial.node import hex'
10 from mercurial import encoding, error, util, obsolete, phases
10 from mercurial import encoding, error, util, obsolete, phases
11 import errno, os
11 import errno, os
12
12
13 def valid(mark):
13 def checkvalid(mark):
14 for c in (':', '\0', '\n', '\r'):
14 for c in (':', '\0', '\n', '\r'):
15 if c in mark:
15 if c in mark:
16 return False
16 raise util.Abort(_("bookmark '%s' contains illegal "
17 return True
17 "character" % mark))
18
18
19 def read(repo):
19 def read(repo):
20 '''Parse .hg/bookmarks file and return a dictionary
20 '''Parse .hg/bookmarks file and return a dictionary
@@ -80,9 +80,7 b' def write(repo):'
80 if repo._bookmarkcurrent not in refs:
80 if repo._bookmarkcurrent not in refs:
81 setcurrent(repo, None)
81 setcurrent(repo, None)
82 for mark in refs.keys():
82 for mark in refs.keys():
83 if not valid(mark):
83 checkvalid(mark)
84 raise util.Abort(_("bookmark '%s' contains illegal "
85 "character" % mark))
86
84
87 wlock = repo.wlock()
85 wlock = repo.wlock()
88 try:
86 try:
@@ -113,9 +111,7 b' def setcurrent(repo, mark):'
113
111
114 if mark not in repo._bookmarks:
112 if mark not in repo._bookmarks:
115 mark = ''
113 mark = ''
116 if not valid(mark):
114 checkvalid(mark)
117 raise util.Abort(_("bookmark '%s' contains illegal "
118 "character" % mark))
119
115
120 wlock = repo.wlock()
116 wlock = repo.wlock()
121 try:
117 try:
General Comments 0
You need to be logged in to leave comments. Login now