# HG changeset patch # User Yuya Nishihara # Date 2017-07-08 03:49:46 # Node ID 371f59c6a89e6eb98fe4502a69877dbc14f25dc1 # Parent 16ed67164002b5cdb9ce8f35ee24c4408076ce0f revset: do not compute weight for integer literal argument In x^n and x~n, n isn't a set expression. There's no need to optimize the right-hand side. diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -476,11 +476,15 @@ def _optimize(x, small): o = _optimize(x[1], small) order = x[2] return o[0], (op, o[1], order) - elif op in ('dagrange', 'range', 'parent', 'ancestor'): + elif op in ('dagrange', 'range'): wa, ta = _optimize(x[1], small) wb, tb = _optimize(x[2], small) order = x[3] return wa + wb, (op, ta, tb, order) + elif op in ('parent', 'ancestor'): + w, t = _optimize(x[1], small) + order = x[3] + return w, (op, t, x[2], order) elif op == 'list': ws, ts = zip(*(_optimize(y, small) for y in x[1:])) return sum(ws), (op,) + ts