# HG changeset patch # User Yuya Nishihara # Date 1439103996 -32400 # Node ID 4f703dcc626f4118bf6643e5ea4d1c23d476d69f # Parent 23c4589fc678a319253938d8dad6cf8eae9fc644 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. diff -r 23c4589fc678 -r 4f703dcc626f mercurial/revset.py --- a/mercurial/revset.py Sat Aug 08 14:42:27 2015 +0800 +++ b/mercurial/revset.py Sun Aug 09 16:06:36 2015 +0900 @@ -2245,8 +2245,10 @@ # (::x and not ::y)/(not ::y and ::x) have a fast path def isonly(revs, bases): return ( - revs[0] == 'func' + revs is not None + and revs[0] == 'func' and getstring(revs[1], _('not a symbol')) == 'ancestors' + and bases is not None and bases[0] == 'not' and bases[1][0] == 'func' and getstring(bases[1][1], _('not a symbol')) == 'ancestors') diff -r 23c4589fc678 -r 4f703dcc626f tests/test-revset.t --- a/tests/test-revset.t Sat Aug 08 14:42:27 2015 +0800 +++ b/tests/test-revset.t Sun Aug 09 16:06:36 2015 +0900 @@ -1230,6 +1230,23 @@ 5 6 +no crash by empty group "()" while optimizing to "only()" + + $ try --optimize '::1 and ()' + (and + (dagrangepre + ('symbol', '1')) + (group + None)) + * optimized: + (and + None + (func + ('symbol', 'ancestors') + ('symbol', '1'))) + hg: parse error: missing argument + [255] + we can use patterns when searching for tags $ log 'tag("1..*")'