comparison mercurial/revset.py @ 29118:8c295c3b2ce2

revset: introduce temporary variables in optimize() where they look better
author Yuya Nishihara <yuya@tcha.org>
date Mon, 02 May 2016 12:47:09 +0900
parents 7828cadd2873
children a032ebea4e97
comparison
equal deleted inserted replaced
29117:7828cadd2873 29118:8c295c3b2ce2
2097 2097
2098 op = x[0] 2098 op = x[0]
2099 if op == 'minus': 2099 if op == 'minus':
2100 return optimize(('and', x[1], ('not', x[2])), small) 2100 return optimize(('and', x[1], ('not', x[2])), small)
2101 elif op == 'only': 2101 elif op == 'only':
2102 return optimize(('func', ('symbol', 'only'), 2102 t = ('func', ('symbol', 'only'), ('list', x[1], x[2]))
2103 ('list', x[1], x[2])), small) 2103 return optimize(t, small)
2104 elif op == 'onlypost': 2104 elif op == 'onlypost':
2105 return optimize(('func', ('symbol', 'only'), x[1]), small) 2105 return optimize(('func', ('symbol', 'only'), x[1]), small)
2106 elif op == 'dagrangepre': 2106 elif op == 'dagrangepre':
2107 return optimize(('func', ('symbol', 'ancestors'), x[1]), small) 2107 return optimize(('func', ('symbol', 'ancestors'), x[1]), small)
2108 elif op == 'dagrangepost': 2108 elif op == 'dagrangepost':
2112 elif op == 'rangepre': 2112 elif op == 'rangepre':
2113 return optimize(('range', ('string', '0'), x[1]), small) 2113 return optimize(('range', ('string', '0'), x[1]), small)
2114 elif op == 'rangepost': 2114 elif op == 'rangepost':
2115 return optimize(('range', x[1], ('string', 'tip')), small) 2115 return optimize(('range', x[1], ('string', 'tip')), small)
2116 elif op == 'negate': 2116 elif op == 'negate':
2117 return optimize(('string', 2117 s = getstring(x[1], _("can't negate that"))
2118 '-' + getstring(x[1], _("can't negate that"))), small) 2118 return optimize(('string', '-' + s), small)
2119 elif op in 'string symbol negate': 2119 elif op in 'string symbol negate':
2120 return smallbonus, x # single revisions are small 2120 return smallbonus, x # single revisions are small
2121 elif op == 'and': 2121 elif op == 'and':
2122 wa, ta = optimize(x[1], True) 2122 wa, ta = optimize(x[1], True)
2123 wb, tb = optimize(x[2], True) 2123 wb, tb = optimize(x[2], True)