From patchwork Thu Jul 13 16:16:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1,of,3] revset: do not compute weight for integer literal argument From: Yuya Nishihara X-Patchwork-Id: 22294 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Fri, 14 Jul 2017 01:16:17 +0900 # HG changeset patch # User Yuya Nishihara # Date 1499485786 -32400 # Sat Jul 08 12:49:46 2017 +0900 # Node ID f98c5d417af06e54df22a58fa2e6305ff7b5a7ba # Parent 0d5afd360e9ec118081c2e2ed5146af80086c49a 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