From 1810576af5b9ee3eeb47b13f04031e2667bfa1c8 Mon Sep 17 00:00:00 2001 From: James Sully Date: Thu, 7 Sep 2023 16:24:40 +1000 Subject: [PATCH] revset: add ancestors_range() method --- lib/src/revset.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index abc78d8e32..098e1ac21e 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -524,11 +524,7 @@ impl RevsetExpression { /// Ancestors of `self`, including `self`. pub fn ancestors(self: &Rc) -> Rc { - 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) -> Rc { Rc::new(RevsetExpression::Ancestors { @@ -540,9 +536,14 @@ impl RevsetExpression { /// Ancestors of `self`, including `self` until `generation` back. pub fn ancestors_at(self: &Rc, generation: u64) -> Rc { + self.ancestors_range(generation..(generation + 1)) + } + + /// Ancestors of `self` in the given range. + pub fn ancestors_range(self: &Rc, generation_range: Range) -> Rc { Rc::new(RevsetExpression::Ancestors { heads: self.clone(), - generation: generation..(generation + 1), + generation: generation_range, is_legacy: false, }) }