[PATCH 3 of 3 V4] revset: skip legacy lookup for revspec wrapped in 'revset(…)'

Yuya Nishihara yuya at tcha.org
Sat Apr 14 09:30:01 EDT 2018


On Sat, 14 Apr 2018 15:07:06 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1523369212 -7200
> #      Tue Apr 10 16:06:52 2018 +0200
> # Node ID e345b7103fef40be16f792cda46aa899d0ef8dd1
> # Parent  304b6671aa1be37fc410edb38f2f2f3040ce6708
> # EXP-Topic noname
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e345b7103fef
> revset: skip legacy lookup for revspec wrapped in 'revset(…)'

>  def matchany(ui, specs, repo=None, localalias=None):
>      """Create a matcher that will include any revisions matching one of the
>      given specs
> @@ -2196,7 +2199,13 @@ def matchany(ui, specs, repo=None, local
>          lookup = lookupfn(repo)
>      parsedspecs = []
>      for s in specs:
> -        parsedspecs.append(revsetlang.parse(s, lookup))
> +        lookupthis = lookup
> +        stripped = s.strip()
> +        if (stripped.startswith(prefixrevset)
> +                and stripped.endswith(postfixrevset)):
> +            s = s[len(prefixrevset):-len(postfixrevset)]
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This would confuse the error reporting. Instead maybe we can handle this
hack in revsetlang.py.

 1) nullify lookup function at revsetlang.parse(), _parsewith(), or
    tokenize()
 2) and, rewrite (func 'revset' x[2]) to x[2] by _analyze()

(2) would be something like

    elif op == 'func':
        f = getsymbol(x[1])
        if f == 'revset':
            return _analyze(x[2])

"hg debugrevspec -v" will show how the parsed tree will be rewritten.


More information about the Mercurial-devel mailing list