Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revsetlang.py @ 34280:b0790bebfcf8
revset: move weight information to predicate
Previously revset weight is hardcoded and cannot be modified. This patch
moves it to predicate so newly registered revsets could define their weight
to properly give static optimization some hint.
Differential Revision: https://phab.mercurial-scm.org/D657
author | Jun Wu <quark@fb.com> |
---|---|
date | Fri, 01 Sep 2017 19:42:09 -0700 |
parents | 53fb09c73ba8 |
children | dd911f95cbda |
line wrap: on
line diff
--- a/mercurial/revsetlang.py Fri Sep 01 19:30:40 2017 -0700 +++ b/mercurial/revsetlang.py Fri Sep 01 19:42:09 2017 -0700 @@ -49,6 +49,8 @@ keywords = {'and', 'or', 'not'} +symbols = {} + _quoteletters = {'"', "'"} _simpleopletters = set(pycompat.iterbytestr("()[]#:=,-|&+!~^%")) @@ -441,21 +443,7 @@ elif op == 'func': f = getsymbol(x[1]) wa, ta = _optimize(x[2]) - if f in ('author', 'branch', 'closed', 'date', 'desc', 'file', 'grep', - 'keyword', 'outgoing', 'user', 'destination'): - w = 10 # slow - elif f in ('modifies', 'adds', 'removes'): - w = 30 # slower - elif f == "contains": - w = 100 # very slow - elif f == "ancestor": - w = 0.5 - elif f in ('reverse', 'limit', 'first', 'wdir', '_intlist'): - w = 0 - elif f == "sort": - w = 10 # assume most sorts look at changelog - else: - w = 1 + w = getattr(symbols.get(f), '_weight', 1) return w + wa, (op, x[1], ta) raise ValueError('invalid operator %r' % op)