mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-28 17:41:14 +00:00
revset: resolve candidates of children set prior to evaluation
This commit is contained in:
parent
7974269bab
commit
f43f0d24b8
2 changed files with 14 additions and 8 deletions
|
@ -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,
|
||||
|
|
|
@ -462,7 +462,10 @@ pub enum ResolvedPredicateExpression {
|
|||
pub enum ResolvedExpression {
|
||||
All, // TODO: should be substituted at resolve_visibility()
|
||||
Commits(Vec<CommitId>),
|
||||
Children(Box<ResolvedExpression>), // TODO: add heads: VisibleHeads
|
||||
Children {
|
||||
roots: Box<ResolvedExpression>,
|
||||
heads: Box<ResolvedExpression>,
|
||||
},
|
||||
Ancestors {
|
||||
heads: Box<ResolvedExpression>,
|
||||
generation: Range<u32>,
|
||||
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue