comparison mercurial/parser.py @ 28897:c1f254138f44

parser: add short comment how aliases are expanded in phases
author Yuya Nishihara <yuya@tcha.org>
date Tue, 29 Mar 2016 16:30:59 +0900
parents 4c76a032ec7e
children 8d398155bfda
comparison
equal deleted inserted replaced
28896:4c76a032ec7e 28897:c1f254138f44
516 raise error.Abort(a.error) 516 raise error.Abort(a.error)
517 if a in expanding: 517 if a in expanding:
518 raise error.ParseError(_('infinite expansion of %(section)s ' 518 raise error.ParseError(_('infinite expansion of %(section)s '
519 '"%(name)s" detected') 519 '"%(name)s" detected')
520 % {'section': cls._section, 'name': a.name}) 520 % {'section': cls._section, 'name': a.name})
521 # get cacheable replacement tree by expanding aliases recursively
521 expanding.append(a) 522 expanding.append(a)
522 if a.name not in cache: 523 if a.name not in cache:
523 cache[a.name] = cls._expand(aliases, a.replacement, expanding, 524 cache[a.name] = cls._expand(aliases, a.replacement, expanding,
524 cache) 525 cache)
525 result = cache[a.name] 526 result = cache[a.name]
526 expanding.pop() 527 expanding.pop()
527 if a.args is None: 528 if a.args is None:
528 return result 529 return result
530 # substitute function arguments in replacement tree
529 l = cls._getlist(tree[2]) 531 l = cls._getlist(tree[2])
530 if len(l) != len(a.args): 532 if len(l) != len(a.args):
531 raise error.ParseError(_('invalid number of arguments: %d') 533 raise error.ParseError(_('invalid number of arguments: %d')
532 % len(l)) 534 % len(l))
533 l = [cls._expand(aliases, t, [], cache) for t in l] 535 l = [cls._expand(aliases, t, [], cache) for t in l]