revset: extract unresolved commit references to separate enum

This makes it clear what should be resolved at resolve_symbols(). Symbol
is a bit special while parsing function arguments, but it's no different
than the other unresolved references at expression level.
This commit is contained in:
Yuya Nishihara 2023-04-05 21:43:35 +09:00
parent fc65b00020
commit 6d9b836d10
3 changed files with 402 additions and 231 deletions

View file

@ -574,13 +574,7 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> {
expression: &RevsetExpression, expression: &RevsetExpression,
) -> Result<Box<dyn InternalRevset<'index> + 'index>, RevsetEvaluationError> { ) -> Result<Box<dyn InternalRevset<'index> + 'index>, RevsetEvaluationError> {
match expression { match expression {
RevsetExpression::Symbol(_) RevsetExpression::CommitRef(_) | RevsetExpression::Present(_) => {
| RevsetExpression::Branches(_)
| RevsetExpression::RemoteBranches { .. }
| RevsetExpression::Tags
| RevsetExpression::GitRefs
| RevsetExpression::GitHead
| RevsetExpression::Present(_) => {
panic!("Expression '{expression:?}' should have been resolved by caller"); panic!("Expression '{expression:?}' should have been resolved by caller");
} }
RevsetExpression::None => Ok(Box::new(EagerRevset::empty())), RevsetExpression::None => Ok(Box::new(EagerRevset::empty())),
@ -740,7 +734,7 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> {
RevsetExpression::None RevsetExpression::None
| RevsetExpression::All | RevsetExpression::All
| RevsetExpression::Commits(_) | RevsetExpression::Commits(_)
| RevsetExpression::Symbol(_) | RevsetExpression::CommitRef(_)
| RevsetExpression::Children(_) | RevsetExpression::Children(_)
| RevsetExpression::Ancestors { .. } | RevsetExpression::Ancestors { .. }
| RevsetExpression::Range { .. } | RevsetExpression::Range { .. }
@ -748,11 +742,6 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> {
| RevsetExpression::Heads(_) | RevsetExpression::Heads(_)
| RevsetExpression::Roots(_) | RevsetExpression::Roots(_)
| RevsetExpression::VisibleHeads | RevsetExpression::VisibleHeads
| RevsetExpression::Branches(_)
| RevsetExpression::RemoteBranches { .. }
| RevsetExpression::Tags
| RevsetExpression::GitRefs
| RevsetExpression::GitHead
| RevsetExpression::Latest { .. } => Ok(self.evaluate(expression)?.into_predicate()), | RevsetExpression::Latest { .. } => Ok(self.evaluate(expression)?.into_predicate()),
RevsetExpression::Filter(predicate) => Ok(build_predicate_fn( RevsetExpression::Filter(predicate) => Ok(build_predicate_fn(
self.store.clone(), self.store.clone(),

File diff suppressed because it is too large Load diff

View file

@ -31,12 +31,12 @@ fn test_debug_revset() {
]}, { ]}, {
assert_snapshot!(stdout, @r###" assert_snapshot!(stdout, @r###"
-- Parsed: -- Parsed:
Symbol( CommitRef(
.. ..
) )
-- Optimized: -- Optimized:
Symbol( CommitRef(
.. ..
) )