diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index 988d6d935..24d2007ab 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -588,10 +588,11 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> { ResolvedExpression::Commits(commit_ids) => { Ok(Box::new(self.revset_for_commit_ids(commit_ids))) } - ResolvedExpression::Children(roots) => { + ResolvedExpression::Children { roots, heads } => { let root_set = self.evaluate(roots)?; - let head_set = self.revset_for_commit_ids(self.visible_heads); - let (walk, root_positions) = self.walk_ancestors_until_roots(&*root_set, &head_set); + let head_set = self.evaluate(heads)?; + let (walk, root_positions) = + self.walk_ancestors_until_roots(&*root_set, &*head_set); let roots: HashSet<_> = root_positions.into_iter().collect(); let candidates = Box::new(RevWalkRevset { walk }); let predicate = pure_predicate_fn(move |entry| { @@ -600,7 +601,8 @@ impl<'index, 'heads> EvaluationContext<'index, 'heads> { .iter() .any(|parent_pos| roots.contains(parent_pos)) }); - // TODO: ToPredicateFn version can be optimized to only test the predicate() + // TODO: Suppose heads include all visible heads, ToPredicateFn version can be + // optimized to only test the predicate() Ok(Box::new(FilterRevset { candidates, predicate, diff --git a/lib/src/revset.rs b/lib/src/revset.rs index c324b7751..f051fb067 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -462,7 +462,10 @@ pub enum ResolvedPredicateExpression { pub enum ResolvedExpression { All, // TODO: should be substituted at resolve_visibility() Commits(Vec), - Children(Box), // TODO: add heads: VisibleHeads + Children { + roots: Box, + heads: Box, + }, Ancestors { heads: Box, generation: Range, @@ -1823,9 +1826,10 @@ impl VisibilityResolutionContext { RevsetExpression::CommitRef(_) => { panic!("Expression '{expression:?}' should have been resolved by caller"); } - RevsetExpression::Children(roots) => { - ResolvedExpression::Children(self.resolve(roots).into()) - } + RevsetExpression::Children(roots) => ResolvedExpression::Children { + roots: self.resolve(roots).into(), + heads: self.resolve_visible_heads().into(), + }, RevsetExpression::Ancestors { heads, generation } => ResolvedExpression::Ancestors { heads: self.resolve(heads).into(), generation: generation.clone(),