diff -r f610d705c3ca -r de5bf3fe0233 mercurial/revsetlang.py --- a/mercurial/revsetlang.py Tue Apr 09 14:41:48 2024 +0200 +++ b/mercurial/revsetlang.py Fri Apr 05 11:05:54 2024 +0200 @@ -392,7 +392,7 @@ elif op == b'negate': s = getstring(x[1], _(b"can't negate that")) return _analyze((b'string', b'-' + s)) - elif op in (b'string', b'symbol', b'smartset'): + elif op in (b'string', b'symbol', b'smartset', b'nodeset'): return x elif op == b'rangeall': return (op, None) @@ -441,8 +441,9 @@ return 0, x op = x[0] - if op in (b'string', b'symbol', b'smartset'): - return 0.5, x # single revisions are small + if op in (b'string', b'symbol', b'smartset', b'nodeset'): + # single revisions are small, and set of already computed revision are assumed to be cheap. + return 0.5, x elif op == b'and': wa, ta = _optimize(x[1]) wb, tb = _optimize(x[2]) @@ -784,6 +785,8 @@ if isinstance(arg, set): arg = sorted(arg) ret.append(_formatintlist(list(arg))) + elif t == b'nodeset': + ret.append(_formatlistexp(list(arg), b"n")) else: raise error.ProgrammingError(b"unknown revspec item type: %r" % t) return b''.join(ret) @@ -801,6 +804,10 @@ newtree = (b'smartset', smartset.baseset(arg)) inputs.append(newtree) ret.append(b"$") + elif t == b'nodeset': + newtree = (b'nodeset', arg) + inputs.append(newtree) + ret.append(b"$") else: raise error.ProgrammingError(b"unknown revspec item type: %r" % t) expr = b''.join(ret) @@ -863,6 +870,12 @@ ret.append((b'baseset', arg)) pos += 1 continue + elif islist and d == b'n' and arg: + # we cannot turn the node into revision yet, but not + # serializing them will same a lot of time for large set. + ret.append((b'nodeset', arg)) + pos += 1 + continue try: ret.append((None, f(list(arg), d))) except (TypeError, ValueError):