Skip to content

Commit

Permalink
revset: parameterize candidates set of FilterRevset as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Dec 15, 2023
1 parent 65de6eb commit 00a3213
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/src/default_revset_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,16 @@ fn predicate_fn_from_positions<'iter>(
}

#[derive(Debug)]
struct FilterRevset<P> {
candidates: Box<dyn InternalRevset>,
struct FilterRevset<S, P> {
candidates: S,
predicate: P,
}

impl<P: ToPredicateFn> InternalRevset for FilterRevset<P> {
impl<S, P> InternalRevset for FilterRevset<S, P>
where
S: InternalRevset,
P: ToPredicateFn,
{
fn iter<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
Expand All @@ -328,7 +332,11 @@ impl<P: ToPredicateFn> InternalRevset for FilterRevset<P> {
}
}

impl<P: ToPredicateFn> ToPredicateFn for FilterRevset<P> {
impl<S, P> ToPredicateFn for FilterRevset<S, P>
where
S: ToPredicateFn,
P: ToPredicateFn,
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
Expand Down Expand Up @@ -703,13 +711,13 @@ impl<'index> EvaluationContext<'index> {
.collect_vec();
if generation_from_roots == &(1..2) {
let root_positions_set: HashSet<_> = root_positions.iter().copied().collect();
let candidates = Box::new(RevWalkRevset::new(move |index| {
let candidates = RevWalkRevset::new(move |index| {
Box::new(
index
.walk_revs(&head_positions, &[])
.take_until_roots(&root_positions),
)
}));
});
let predicate = as_pure_predicate_fn(move |_index, entry| {
entry
.parent_positions()
Expand Down

0 comments on commit 00a3213

Please sign in to comment.