Mercurial > hg > mercurial-source
comparison mercurial/revset.py @ 25505:8b99e9a8db05 stable
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)'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 15 May 2015 22:32:31 +0900 |
parents | b5c227f3e461 |
children | bb2f543b48b5 e16456831516 |
comparison
equal
deleted
inserted
replaced
25461:bd98d073a34f | 25505:8b99e9a8db05 |
---|---|
2096 "func": func, | 2096 "func": func, |
2097 "ancestor": ancestorspec, | 2097 "ancestor": ancestorspec, |
2098 "parent": parentspec, | 2098 "parent": parentspec, |
2099 "parentpost": p1, | 2099 "parentpost": p1, |
2100 "only": only, | 2100 "only": only, |
2101 "onlypost": only, | |
2102 } | 2101 } |
2103 | 2102 |
2104 def optimize(x, small): | 2103 def optimize(x, small): |
2105 if x is None: | 2104 if x is None: |
2106 return 0, x | 2105 return 0, x |
2113 if op == 'minus': | 2112 if op == 'minus': |
2114 return optimize(('and', x[1], ('not', x[2])), small) | 2113 return optimize(('and', x[1], ('not', x[2])), small) |
2115 elif op == 'only': | 2114 elif op == 'only': |
2116 return optimize(('func', ('symbol', 'only'), | 2115 return optimize(('func', ('symbol', 'only'), |
2117 ('list', x[1], x[2])), small) | 2116 ('list', x[1], x[2])), small) |
2117 elif op == 'onlypost': | |
2118 return optimize(('func', ('symbol', 'only'), x[1]), small) | |
2118 elif op == 'dagrangepre': | 2119 elif op == 'dagrangepre': |
2119 return optimize(('func', ('symbol', 'ancestors'), x[1]), small) | 2120 return optimize(('func', ('symbol', 'ancestors'), x[1]), small) |
2120 elif op == 'dagrangepost': | 2121 elif op == 'dagrangepost': |
2121 return optimize(('func', ('symbol', 'descendants'), x[1]), small) | 2122 return optimize(('func', ('symbol', 'descendants'), x[1]), small) |
2122 elif op == 'rangepre': | 2123 elif op == 'rangepre': |