[PATCH 3 of 3] revset: do not partial-match operator and function names in optimize()
Yuya Nishihara
yuya at tcha.org
Fri Sep 2 10:58:12 EDT 2016
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1470555368 -32400
# Sun Aug 07 16:36:08 2016 +0900
# Node ID 1c24a66616699350c48aee283da06906ec9b4efa
# Parent 04d0742aa7ecb239a06ba46e9f8ebe0c52a86e9d
revset: do not partial-match operator and function names in optimize()
It was error-prone, and actually there was a typo, s/ancestorspec/ancestor/.
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2371,7 +2371,7 @@ def _optimize(x, small):
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 @@ def _optimize(x, small):
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 @@ def _optimize(x, small):
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
More information about the Mercurial-devel
mailing list