comparison mercurial/revset.py @ 25995:4f703dcc626f stable

revset: prevent crash caused by empty group expression while optimizing "and" An empty group expression "()" generates None in AST, so the optimizer have to test it before destructuring a tuple. The error message, "missing argument", is somewhat obscure, but it should be better than crash.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 09 Aug 2015 16:06:36 +0900
parents be29d26e2949
children b12e00a05d57
comparison
equal deleted inserted replaced
25925:23c4589fc678 25995:4f703dcc626f
2243 wb, tb = optimize(x[2], True) 2243 wb, tb = optimize(x[2], True)
2244 2244
2245 # (::x and not ::y)/(not ::y and ::x) have a fast path 2245 # (::x and not ::y)/(not ::y and ::x) have a fast path
2246 def isonly(revs, bases): 2246 def isonly(revs, bases):
2247 return ( 2247 return (
2248 revs[0] == 'func' 2248 revs is not None
2249 and revs[0] == 'func'
2249 and getstring(revs[1], _('not a symbol')) == 'ancestors' 2250 and getstring(revs[1], _('not a symbol')) == 'ancestors'
2251 and bases is not None
2250 and bases[0] == 'not' 2252 and bases[0] == 'not'
2251 and bases[1][0] == 'func' 2253 and bases[1][0] == 'func'
2252 and getstring(bases[1][1], _('not a symbol')) == 'ancestors') 2254 and getstring(bases[1][1], _('not a symbol')) == 'ancestors')
2253 2255
2254 w = min(wa, wb) 2256 w = min(wa, wb)