##// 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 simplified.append(simplifyinfixops(x, targetnodes))
220 simplified.append(simplifyinfixops(x, targetnodes))
221 simplified.append(op)
221 simplified.append(op)
222 return tuple(reversed(simplified))
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 pos += 1
300 pos += 1
301 yield ('end', None, pos)
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 # helpers
303 # helpers
312
304
313 def getstring(x, err):
305 def getstring(x, err):
@@ -2312,7 +2304,7 b' def _parsealiasdecl(decl):'
2312
2304
2313 return (decl, None, None, _("invalid format"))
2305 return (decl, None, None, _("invalid format"))
2314 except error.ParseError as inst:
2306 except error.ParseError as inst:
2315 return (decl, None, None, parseerrordetail(inst))
2307 return (decl, None, None, parser.parseerrordetail(inst))
2316
2308
2317 def _relabelaliasargs(tree, args):
2309 def _relabelaliasargs(tree, args):
2318 if not isinstance(tree, tuple):
2310 if not isinstance(tree, tuple):
@@ -2349,7 +2341,7 b' def _parsealiasdefn(defn, args):'
2349 >>> try:
2341 >>> try:
2350 ... _parsealiasdefn('$1 or $bar', args)
2342 ... _parsealiasdefn('$1 or $bar', args)
2351 ... except error.ParseError, inst:
2343 ... except error.ParseError, inst:
2352 ... print parseerrordetail(inst)
2344 ... print parser.parseerrordetail(inst)
2353 '$' not for alias arguments
2345 '$' not for alias arguments
2354 >>> args = ['$1', '$10', 'foo']
2346 >>> args = ['$1', '$10', 'foo']
2355 >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
2347 >>> print prettyformat(_parsealiasdefn('$10 or foobar', args))
@@ -2394,7 +2386,8 b' class revsetalias(object):'
2394 self.replacement = _parsealiasdefn(value, self.args)
2386 self.replacement = _parsealiasdefn(value, self.args)
2395 except error.ParseError as inst:
2387 except error.ParseError as inst:
2396 self.error = _('failed to parse the definition of revset alias'
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 def _getalias(aliases, tree):
2392 def _getalias(aliases, tree):
2400 """If tree looks like an unexpanded alias, return it. Return None
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