[PATCH 8 of 8] revset: introduce an API that avoids `formatspec` input serialization

Yuya Nishihara yuya at tcha.org
Sun Jan 13 21:09:00 EST 2019


On Sun, 13 Jan 2019 18:53:13 +0900, Yuya Nishihara wrote:
> So here we have string to parse, b''.join(ret), and replacements, inputs.
> If b''.join(ret) contained '$0' instead of 'internal(0)', and if inputs
> were dict of {'$0': alias('$0', ..., ('smartset', inputs[0]))}, we can just
> feed them to _aliasrules.
> 
>   aliases = build_dict_of_inputs(inputs)
>   tree = _parsewith(b''.join(ret), syminitletters=_aliassyminitletters)
>   tree = _aliasrules.expand(aliases, tree)

Actually there's a simpler tool, parser.buildtree(). We still need an invalid
placeholder symbol that can be parsed, e.g. '$', but we don't have to care
about the internals of the alias expansion.

  tree = _parsewith(b''.join(ret), syminitletters=_aliassyminitletters)
  tree = parser.buildtree(tree, ('symbol', '$'), ('smartset', inputs[0]), ...)


More information about the Mercurial-devel mailing list