# HG changeset patch # User Yuya Nishihara # Date 1431696751 -32400 # Node ID 8b99e9a8db05d77937a9905cc77e946171159acc # Parent bd98d073a34fcf9651a77a9265878db1f7c88044 revset: map postfix '%' to only() to optimize operand recursively (issue4670) Instead of keeping 'onlypost' as a method, this patch rewrites it to 'only' function. This way, 'x%' always has the same weight as 'only(x)'. diff -r bd98d073a34f -r 8b99e9a8db05 mercurial/revset.py --- a/mercurial/revset.py Sun May 10 10:57:24 2015 -0400 +++ b/mercurial/revset.py Fri May 15 22:32:31 2015 +0900 @@ -2098,7 +2098,6 @@ "parent": parentspec, "parentpost": p1, "only": only, - "onlypost": only, } def optimize(x, small): @@ -2115,6 +2114,8 @@ elif op == 'only': return optimize(('func', ('symbol', 'only'), ('list', x[1], x[2])), small) + elif op == 'onlypost': + return optimize(('func', ('symbol', 'only'), x[1]), small) elif op == 'dagrangepre': return optimize(('func', ('symbol', 'ancestors'), x[1]), small) elif op == 'dagrangepost': diff -r bd98d073a34f -r 8b99e9a8db05 tests/test-revset.t --- a/tests/test-revset.t Sun May 10 10:57:24 2015 -0400 +++ b/tests/test-revset.t Fri May 15 22:32:31 2015 +0900 @@ -533,6 +533,29 @@ 8 9 +Test opreand of '%' is optimized recursively (issue4670) + + $ try --optimize '8:9-8%' + (onlypost + (minus + (range + ('symbol', '8') + ('symbol', '9')) + ('symbol', '8'))) + * optimized: + (func + ('symbol', 'only') + (and + (range + ('symbol', '8') + ('symbol', '9')) + (not + ('symbol', '8')))) + * set: + + 8 + 9 + Test the order of operations $ log '7 + 9%5 + 2'