changeset 29898:7203400f91b0

revset: do not partial-match operator and function names in optimize() It was error-prone, and actually there was a typo, s/ancestorspec/ancestor/.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 07 Aug 2016 16:36:08 +0900
parents 90a1886a203b
children a9b92164a1f4
files mercurial/revset.py
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revset.py	Sun Aug 07 14:13:27 2016 +0900
+++ b/mercurial/revset.py	Sun Aug 07 16:36:08 2016 +0900
@@ -2371,7 +2371,7 @@
     elif op == 'negate':
         s = getstring(x[1], _("can't negate that"))
         return _optimize(('string', '-' + s), small)
-    elif op in 'string symbol':
+    elif op in ('string', 'symbol'):
         return smallbonus, x # single revisions are small
     elif op == 'and':
         wa, ta = _optimize(x[1], True)
@@ -2434,7 +2434,7 @@
         return o[0], (op, o[1])
     elif op == 'group':
         return _optimize(x[1], small)
-    elif op in 'dagrange range parent ancestorspec':
+    elif op in ('dagrange', 'range', 'parent', 'ancestor'):
         wa, ta = _optimize(x[1], small)
         wb, tb = _optimize(x[2], small)
         return wa + wb, (op, ta, tb)
@@ -2447,18 +2447,18 @@
     elif op == 'func':
         f = getsymbol(x[1])
         wa, ta = _optimize(x[2], small)
-        if f in ("author branch closed date desc file grep keyword "
-                 "outgoing user"):
+        if f in ('author', 'branch', 'closed', 'date', 'desc', 'file', 'grep',
+                 'keyword', 'outgoing', 'user'):
             w = 10 # slow
-        elif f in "modifies adds removes":
+        elif f in ('modifies', 'adds', 'removes'):
             w = 30 # slower
         elif f == "contains":
             w = 100 # very slow
         elif f == "ancestor":
             w = 1 * smallbonus
-        elif f in "reverse limit first _intlist":
+        elif f in ('reverse', 'limit', 'first', '_intlist'):
             w = 0
-        elif f in "sort":
+        elif f == "sort":
             w = 10 # assume most sorts look at changelog
         else:
             w = 1