Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revsetlang.py @ 32931:3292c0df64f7
revsetlang: check arguments passed to ancestors() before optimizing to only()
Future patches will add depth parameter to ancestors(), which isn't compatible
with only().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Jun 2017 11:57:28 +0900 |
parents | c808507cfbf0 |
children | 4672db164c98 |
line wrap: on
line diff
--- a/mercurial/revsetlang.py Sun Jun 18 11:39:03 2017 +0900 +++ b/mercurial/revsetlang.py Sun Jun 18 11:57:28 2017 +0900 @@ -240,6 +240,11 @@ """Check if given tree matches named function""" return x and x[0] == 'func' and getsymbol(x[1]) == funcname +def _isposargs(x, n): + """Check if given tree is n-length list of positional arguments""" + l = getlist(x) + return len(l) == n and all(y and y[0] != 'keyvalue' for y in l) + def _matchnamedfunc(x, funcname): """Return args tree if given tree matches named function; otherwise None @@ -302,7 +307,7 @@ """ ta = _matchnamedfunc(revs, 'ancestors') tb = bases and bases[0] == 'not' and _matchnamedfunc(bases[1], 'ancestors') - if ta and tb: + if _isposargs(ta, 1) and _isposargs(tb, 1): return ('list', ta, tb) def _fixops(x):