##// END OF EJS Templates
parser: reorder alias expansion routine to return early...
Yuya Nishihara -
r28896:4c76a032 default
parent child Browse files
Show More
@@ -509,31 +509,29 b' class basealiasrules(object):'
509 if not isinstance(tree, tuple):
509 if not isinstance(tree, tuple):
510 return tree
510 return tree
511 a = cls._getalias(aliases, tree)
511 a = cls._getalias(aliases, tree)
512 if a is not None:
512 if a is None:
513 return tuple(cls._expand(aliases, t, expanding, cache)
514 for t in tree)
513 if a.error:
515 if a.error:
514 raise error.Abort(a.error)
516 raise error.Abort(a.error)
515 if a in expanding:
517 if a in expanding:
516 raise error.ParseError(_('infinite expansion of %(section)s '
518 raise error.ParseError(_('infinite expansion of %(section)s '
517 '"%(name)s" detected')
519 '"%(name)s" detected')
518 % {'section': cls._section,
520 % {'section': cls._section, 'name': a.name})
519 'name': a.name})
520 expanding.append(a)
521 expanding.append(a)
521 if a.name not in cache:
522 if a.name not in cache:
522 cache[a.name] = cls._expand(aliases, a.replacement, expanding,
523 cache[a.name] = cls._expand(aliases, a.replacement, expanding,
523 cache)
524 cache)
524 result = cache[a.name]
525 result = cache[a.name]
525 expanding.pop()
526 expanding.pop()
526 if a.args is not None:
527 if a.args is None:
528 return result
527 l = cls._getlist(tree[2])
529 l = cls._getlist(tree[2])
528 if len(l) != len(a.args):
530 if len(l) != len(a.args):
529 raise error.ParseError(_('invalid number of arguments: %d')
531 raise error.ParseError(_('invalid number of arguments: %d')
530 % len(l))
532 % len(l))
531 l = [cls._expand(aliases, t, [], cache) for t in l]
533 l = [cls._expand(aliases, t, [], cache) for t in l]
532 result = cls._expandargs(result, dict(zip(a.args, l)))
534 return cls._expandargs(result, dict(zip(a.args, l)))
533 else:
534 result = tuple(cls._expand(aliases, t, expanding, cache)
535 for t in tree)
536 return result
537
535
538 @classmethod
536 @classmethod
539 def expand(cls, aliases, tree):
537 def expand(cls, aliases, tree):
General Comments 0
You need to be logged in to leave comments. Login now