D451: revset: remove order information from tree

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Sun Aug 27 08:33:06 EDT 2017


yuja added a comment.


  It seems `_optimize()` has more bugs, so I decided to not queue this.
  I have partially updated patch, but how can I collaborate with you?
  
  FWIW, I think `_optimize()` could use `defineorder/anyorder` constants
  in place of `True/False` for readablity.

INLINE COMMENTS

> revset.py:63
> +        # argument. Maintain compatibility to make developers life easier.
> +        return methods[x[0]](repo, subset, *x[1:])
>  

`methods` is the table of operators, not functions, which wouldn't be modified
by extensions. I'll drop this change.

> revset.py:141
>  def differenceset(repo, subset, x, y, order):
> -    return getset(repo, subset, x) - getset(repo, subset, y)
> +    return getset(repo, subset, x, order) - getset(repo, subset, y)
>  

right-hand side was originally `anyorder`, so updated in flight.

> revset.py:161
>  def notset(repo, subset, x, order):
>      return subset - getset(repo, subset, x)
>  

This, too. added `anyorder` in flight.

> revset.py:892
> +def _flipand(repo, subset, args, order):
> +    """Equivalent to ``y and x``, but faster when x is small"""
> +    x, y = getargs(args, 2, 2, _("missing argument"))

This should be undocumented. Changed to a comment.

> revsetlang.py:354
> +                'dagrange', 'range', 'parent', 'ancestor', 'relation',
> +                'subscript', 'relsubscript', 'list'}:
> +        return (op,) + tuple(_analyze(y) for y in x[1:])

Split this back to unary/binary/ternary cases since I slightly prefer
explicit handling of node tuples.

> revsetlang.py:435
> +            newsym = ('func', ('symbol', '_notpublic'), None)
> +            o = _optimize(newsym, not small, False)
>              return o[0], o[1]

Perhaps this should keep the current `preserveorder` since
`not public()` is fully replaced with `_notpublic()`.

> revsetlang.py:443
>      elif op in ('rangepre', 'rangepost', 'parentpost'):
> -        o = _optimize(x[1], small)
> -        order = x[2]
> -        return o[0], (op, o[1], order)
> +        o = _optimize(x[1], small, False)
> +        return o[0], (op, o[1])

The order matters. Try `(contains("glob:") & 2:0):1` for example.

> revsetlang.py:459
>      elif op == 'keyvalue':
> -        w, t = _optimize(x[2], small)
> +        w, t = _optimize(x[2], small, True)
>          return w, (op, x[1], t)

Perhaps this is `preserveorder` since `keyvalue` node isn't a
standalone expression.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D451

To: quark, #hg-reviewers
Cc: martinvonz, yuja, mercurial-devel


More information about the Mercurial-devel mailing list