Mercurial > hg
comparison tests/test-revset.t @ 25996:b12e00a05d57 stable
revset: prevent crash caused by empty group expression while optimizing "or"
An empty group expression "()" generates None in AST, so it should be tested
before destructuring a tuple.
"A | ()" is still evaluated to an error because I'm not sure whether "()"
represents an empty set or an empty expression (= a unit value). They are
identical in "or" operation, but they should be evaluated differently in
"and" operation.
expression empty set unit value
---------- --------- ----------
() {} A
A & () {} A
A | () A A
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 09 Aug 2015 16:09:41 +0900 |
parents | 4f703dcc626f |
children | a7527c5769bb |
comparison
equal
deleted
inserted
replaced
25995:4f703dcc626f | 25996:b12e00a05d57 |
---|---|
1142 2 | 1142 2 |
1143 3 | 1143 3 |
1144 4 | 1144 4 |
1145 5 | 1145 5 |
1146 | 1146 |
1147 no crash by empty group "()" while optimizing `or` operations | |
1148 | |
1149 $ try --optimize '0|()' | |
1150 (or | |
1151 ('symbol', '0') | |
1152 (group | |
1153 None)) | |
1154 * optimized: | |
1155 (or | |
1156 ('symbol', '0') | |
1157 None) | |
1158 hg: parse error: missing argument | |
1159 [255] | |
1160 | |
1147 test that chained `or` operations never eat up stack (issue4624) | 1161 test that chained `or` operations never eat up stack (issue4624) |
1148 (uses `0:1` instead of `0` to avoid future optimization of trivial revisions) | 1162 (uses `0:1` instead of `0` to avoid future optimization of trivial revisions) |
1149 | 1163 |
1150 $ hg log -T '{rev}\n' -r "`python -c "print '|'.join(['0:1'] * 500)"`" | 1164 $ hg log -T '{rev}\n' -r "`python -c "print '|'.join(['0:1'] * 500)"`" |
1151 0 | 1165 0 |