Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/parser.py @ 28893:ee11167fe1da
parser: extract helper that creates a dict of aliases
This will be common between revset and templater.
The local variable 'alias' is renamed to 'a' to avoid shadowing the global
'alias' class.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 29 Feb 2016 19:24:15 +0900 |
parents | 0c135f37c6f8 |
children | 4bf9ed7a260e |
comparison
equal
deleted
inserted
replaced
28892:0c135f37c6f8 | 28893:ee11167fe1da |
---|---|
460 efmt = _('failed to parse the definition of %(section)s ' | 460 efmt = _('failed to parse the definition of %(section)s ' |
461 '"%(name)s": %(error)s') | 461 '"%(name)s": %(error)s') |
462 if err: | 462 if err: |
463 err = efmt % {'section': cls._section, 'name': name, 'error': err} | 463 err = efmt % {'section': cls._section, 'name': name, 'error': err} |
464 return alias(name, tree, args, err, repl) | 464 return alias(name, tree, args, err, repl) |
465 | |
466 @classmethod | |
467 def buildmap(cls, items): | |
468 """Parse a list of alias (name, replacement) pairs into a dict of | |
469 alias objects""" | |
470 aliases = {} | |
471 for decl, defn in items: | |
472 a = cls.build(decl, defn) | |
473 aliases[a.name] = a | |
474 return aliases |