Mercurial > hg
changeset 30803:d389f19f14aa
revset: do not transform range* operators in parsed tree
This allows us to handle x:y range as a general range object. A primary user
of it is followlines().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 09 Jan 2017 16:55:56 +0900 |
parents | 5eb3e4568c94 |
children | 4227f80f72b2 |
files | mercurial/revset.py tests/test-revset.t |
diffstat | 2 files changed, 22 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Mon Jan 09 17:45:11 2017 +0900 +++ b/mercurial/revset.py Mon Jan 09 16:55:56 2017 +0900 @@ -380,6 +380,10 @@ return baseset() return _makerangeset(repo, subset, m.first(), n.last(), order) +def rangeall(repo, subset, x, order): + assert x is None + return _makerangeset(repo, subset, 0, len(repo) - 1, order) + def rangepre(repo, subset, y, order): # ':y' can't be rewritten to '0:y' since '0' may be hidden n = getset(repo, fullreposet(repo), y) @@ -387,6 +391,12 @@ return baseset() return _makerangeset(repo, subset, 0, n.last(), order) +def rangepost(repo, subset, x, order): + m = getset(repo, fullreposet(repo), x) + if not m: + return baseset() + return _makerangeset(repo, subset, m.first(), len(repo) - 1, order) + def _makerangeset(repo, subset, m, n, order): if m == n: r = baseset([m]) @@ -2385,7 +2395,9 @@ methods = { "range": rangeset, + "rangeall": rangeall, "rangepre": rangepre, + "rangepost": rangepost, "dagrange": dagrange, "string": stringset, "symbol": stringset, @@ -2500,10 +2512,6 @@ return _analyze(('func', ('symbol', 'ancestors'), x[1]), order) elif op == 'dagrangepost': return _analyze(('func', ('symbol', 'descendants'), x[1]), order) - elif op == 'rangeall': - return _analyze(('rangepre', ('string', 'tip')), order) - elif op == 'rangepost': - return _analyze(('range', x[1], ('string', 'tip')), order) elif op == 'negate': s = getstring(x[1], _("can't negate that")) return _analyze(('string', '-' + s), order) @@ -2517,7 +2525,9 @@ return (op, _analyze(x[1], order), order) elif op == 'not': return (op, _analyze(x[1], anyorder), order) - elif op in ('rangepre', 'parentpost'): + elif op == 'rangeall': + return (op, None, order) + elif op in ('rangepre', 'rangepost', 'parentpost'): return (op, _analyze(x[1], defineorder), order) elif op == 'group': return _analyze(x[1], order) @@ -2622,7 +2632,9 @@ o = _optimize(x[1], not small) order = x[2] return o[0], (op, o[1], order) - elif op in ('rangepre', 'parentpost'): + elif op == 'rangeall': + return smallbonus, x + elif op in ('rangepre', 'rangepost', 'parentpost'): o = _optimize(x[1], small) order = x[2] return o[0], (op, o[1], order)
--- a/tests/test-revset.t Mon Jan 09 17:45:11 2017 +0900 +++ b/tests/test-revset.t Mon Jan 09 16:55:56 2017 +0900 @@ -161,8 +161,8 @@ (rangeall None) * optimized: - (rangepre - ('string', 'tip') + (rangeall + None define) * set: <spanset+ 0:9> @@ -619,8 +619,8 @@ (rangeall None) * analyzed: - (rangepre - ('string', 'tip') + (rangeall + None define) * set: <spanset+ 0:9>