Skip to content

Commit

Permalink
revset: add ancestors_range() method
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Sep 7, 2023
1 parent c4769e0 commit 1810576
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,7 @@ impl RevsetExpression {

/// Ancestors of `self`, including `self`.
pub fn ancestors(self: &Rc<RevsetExpression>) -> Rc<RevsetExpression> {
Rc::new(RevsetExpression::Ancestors {
heads: self.clone(),
generation: GENERATION_RANGE_FULL,
is_legacy: false,
})
self.ancestors_range(GENERATION_RANGE_FULL)
}
fn legacy_ancestors(self: &Rc<RevsetExpression>) -> Rc<RevsetExpression> {
Rc::new(RevsetExpression::Ancestors {
Expand All @@ -540,9 +536,14 @@ impl RevsetExpression {

/// Ancestors of `self`, including `self` until `generation` back.
pub fn ancestors_at(self: &Rc<RevsetExpression>, generation: u64) -> Rc<RevsetExpression> {
self.ancestors_range(generation..(generation + 1))
}

/// Ancestors of `self` in the given range.
pub fn ancestors_range(self: &Rc<RevsetExpression>, generation_range: Range<u64>) -> Rc<RevsetExpression> {
Rc::new(RevsetExpression::Ancestors {
heads: self.clone(),
generation: generation..(generation + 1),
generation: generation_range,
is_legacy: false,
})
}
Expand Down

0 comments on commit 1810576

Please sign in to comment.