From e83072b98fa659de8a879a6a301d3bf3f85e6ed5 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 4 Nov 2024 21:25:29 +0900 Subject: [PATCH] revset: ignore Present node when building backend expression This will become safe as I'm going to add static check that the expression does never contain CommitRef(_)s. We could make Present(_) unconstructible, but the existence of Present node is harmless. --- lib/src/revset.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 2284b6e88..24bc15083 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -2300,9 +2300,8 @@ impl VisibilityResolutionContext<'_> { self.resolve(expression1).into(), self.resolve(expression2).into(), ), - RevsetExpression::Present(_) => { - panic!("Expression '{expression:?}' should have been resolved by caller"); - } + // present(x) is noop if x doesn't contain any commit refs. + RevsetExpression::Present(candidates) => self.resolve(candidates), RevsetExpression::NotIn(complement) => ResolvedExpression::Difference( self.resolve_all().into(), self.resolve(complement).into(), @@ -2392,9 +2391,8 @@ impl VisibilityResolutionContext<'_> { RevsetExpression::Coalesce(_, _) => { ResolvedPredicateExpression::Set(self.resolve(expression).into()) } - RevsetExpression::Present(_) => { - panic!("Expression '{expression:?}' should have been resolved by caller") - } + // present(x) is noop if x doesn't contain any commit refs. + RevsetExpression::Present(candidates) => self.resolve_predicate(candidates), RevsetExpression::NotIn(complement) => { ResolvedPredicateExpression::NotIn(self.resolve_predicate(complement).into()) }