##// END OF EJS Templates
parser: move parsererrordetail() function from revset module...
Yuya Nishihara -
r28720:639e0f1e default
parent child Browse files
Show More
@@ -220,3 +220,11 b' def simplifyinfixops(tree, targetnodes):'
220 220 simplified.append(simplifyinfixops(x, targetnodes))
221 221 simplified.append(op)
222 222 return tuple(reversed(simplified))
223
224 def parseerrordetail(inst):
225 """Compose error message from specified ParseError object
226 """
227 if len(inst.args) > 1:
228 return _('at %s: %s') % (inst.args[1], inst.args[0])
229 else:
230 return inst.args[0]
@@ -300,14 +300,6 b' def tokenize(program, lookup=None, symin'
300 300 pos += 1
301 301 yield ('end', None, pos)
302 302
303 def parseerrordetail(inst):
304 """Compose error message from specified ParseError object
305 """
306 if len(inst.args) > 1:
307 return _('at %s: %s') % (inst.args[1], inst.args[0])
308 else:
309 return inst.args[0]
310
311 303 # helpers
312 304
313 305 def getstring(x, err):
@@ -2312,7 +2304,7 b' def _parsealiasdecl(decl):'
2312 2304
2313 2305 return (decl, None, None, _("invalid format"))
2314 2306 except error.ParseError as inst:
2315 return (decl, None, None, parseerrordetail(inst))
2307 return (decl, None, None, parser.parseerrordetail(inst))
2316 2308
2317 2309 def _relabelaliasargs(tree, args):
2318 2310 if not isinstance(tree, tuple):
@@ -2349,7 +2341,7 b' def _parsealiasdefn(defn, args):'
2349 2341 >>> try:
2350 2342 ... _parsealiasdefn('$1 or $bar', args)
2351 2343 ... except error.ParseError, inst:
2352 ... print parseerrordetail(inst)
2344 ... print parser.parseerrordetail(inst)
2353 2345 '$' not for alias arguments
2354 2346 >>> args = ['$1', '$10', 'foo']
2355 2347 >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
@@ -2394,7 +2386,8 b' class revsetalias(object):'
2394 2386 self.replacement = _parsealiasdefn(value, self.args)
2395 2387 except error.ParseError as inst:
2396 2388 self.error = _('failed to parse the definition of revset alias'
2397 ' "%s": %s') % (self.name, parseerrordetail(inst))
2389 ' "%s": %s') % (self.name,
2390 parser.parseerrordetail(inst))
2398 2391
2399 2392 def _getalias(aliases, tree):
2400 2393 """If tree looks like an unexpanded alias, return it. Return None
General Comments 0
You need to be logged in to leave comments. Login now