Show More
@@ -240,6 +240,11 def _isnamedfunc(x, funcname): | |||||
240 | """Check if given tree matches named function""" |
|
240 | """Check if given tree matches named function""" | |
241 | return x and x[0] == 'func' and getsymbol(x[1]) == funcname |
|
241 | return x and x[0] == 'func' and getsymbol(x[1]) == funcname | |
242 |
|
242 | |||
|
243 | def _isposargs(x, n): | |||
|
244 | """Check if given tree is n-length list of positional arguments""" | |||
|
245 | l = getlist(x) | |||
|
246 | return len(l) == n and all(y and y[0] != 'keyvalue' for y in l) | |||
|
247 | ||||
243 | def _matchnamedfunc(x, funcname): |
|
248 | def _matchnamedfunc(x, funcname): | |
244 | """Return args tree if given tree matches named function; otherwise None |
|
249 | """Return args tree if given tree matches named function; otherwise None | |
245 |
|
250 | |||
@@ -302,7 +307,7 def _matchonly(revs, bases): | |||||
302 | """ |
|
307 | """ | |
303 | ta = _matchnamedfunc(revs, 'ancestors') |
|
308 | ta = _matchnamedfunc(revs, 'ancestors') | |
304 | tb = bases and bases[0] == 'not' and _matchnamedfunc(bases[1], 'ancestors') |
|
309 | tb = bases and bases[0] == 'not' and _matchnamedfunc(bases[1], 'ancestors') | |
305 | if ta and tb: |
|
310 | if _isposargs(ta, 1) and _isposargs(tb, 1): | |
306 | return ('list', ta, tb) |
|
311 | return ('list', ta, tb) | |
307 |
|
312 | |||
308 | def _fixops(x): |
|
313 | def _fixops(x): |
@@ -2980,6 +2980,65 no crash by empty group "()" while optim | |||||
2980 | hg: parse error: missing argument |
|
2980 | hg: parse error: missing argument | |
2981 | [255] |
|
2981 | [255] | |
2982 |
|
2982 | |||
|
2983 | optimization to only() works only if ancestors() takes only one argument | |||
|
2984 | ||||
|
2985 | $ hg debugrevspec -p optimized 'ancestors(6) - ancestors(4, 1)' | |||
|
2986 | * optimized: | |||
|
2987 | (difference | |||
|
2988 | (func | |||
|
2989 | ('symbol', 'ancestors') | |||
|
2990 | ('symbol', '6') | |||
|
2991 | define) | |||
|
2992 | (func | |||
|
2993 | ('symbol', 'ancestors') | |||
|
2994 | (list | |||
|
2995 | ('symbol', '4') | |||
|
2996 | ('symbol', '1')) | |||
|
2997 | any) | |||
|
2998 | define) | |||
|
2999 | hg: parse error: can't use a list in this context | |||
|
3000 | (see hg help "revsets.x or y") | |||
|
3001 | [255] | |||
|
3002 | $ hg debugrevspec -p optimized 'ancestors(6, 1) - ancestors(4)' | |||
|
3003 | * optimized: | |||
|
3004 | (difference | |||
|
3005 | (func | |||
|
3006 | ('symbol', 'ancestors') | |||
|
3007 | (list | |||
|
3008 | ('symbol', '6') | |||
|
3009 | ('symbol', '1')) | |||
|
3010 | define) | |||
|
3011 | (func | |||
|
3012 | ('symbol', 'ancestors') | |||
|
3013 | ('symbol', '4') | |||
|
3014 | any) | |||
|
3015 | define) | |||
|
3016 | hg: parse error: can't use a list in this context | |||
|
3017 | (see hg help "revsets.x or y") | |||
|
3018 | [255] | |||
|
3019 | ||||
|
3020 | optimization disabled if keyword arguments passed (because we're too lazy | |||
|
3021 | to support it) | |||
|
3022 | ||||
|
3023 | $ hg debugrevspec -p optimized 'ancestors(set=6) - ancestors(set=4)' | |||
|
3024 | * optimized: | |||
|
3025 | (difference | |||
|
3026 | (func | |||
|
3027 | ('symbol', 'ancestors') | |||
|
3028 | (keyvalue | |||
|
3029 | ('symbol', 'set') | |||
|
3030 | ('symbol', '6')) | |||
|
3031 | define) | |||
|
3032 | (func | |||
|
3033 | ('symbol', 'ancestors') | |||
|
3034 | (keyvalue | |||
|
3035 | ('symbol', 'set') | |||
|
3036 | ('symbol', '4')) | |||
|
3037 | any) | |||
|
3038 | define) | |||
|
3039 | hg: parse error: can't use a key-value pair in this context | |||
|
3040 | [255] | |||
|
3041 | ||||
2983 | invalid function call should not be optimized to only() |
|
3042 | invalid function call should not be optimized to only() | |
2984 |
|
3043 | |||
2985 | $ log '"ancestors"(6) and not ancestors(4)' |
|
3044 | $ log '"ancestors"(6) and not ancestors(4)' |
General Comments 0
You need to be logged in to leave comments.
Login now