diff --git a/lib/src/revset.rs b/lib/src/revset.rs index b854844f96..e0ef3b2044 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -380,6 +380,15 @@ impl RevsetExpression { }) } + /// Ancestors of `self`, including `self` up to `generations` back. + pub fn ancestors_at(self: &Rc, generations: u64) -> Rc { + Rc::new(RevsetExpression::Ancestors { + heads: self.clone(), + generation: (generations - 1)..generations, + is_legacy: false, + }) + } + /// Children of `self`. pub fn children(self: &Rc) -> Rc { Rc::new(RevsetExpression::Descendants { @@ -405,6 +414,15 @@ impl RevsetExpression { }) } + /// Descendants of `self`, including `self` up to `generations` back. + pub fn descendants_at(self: &Rc, generations: u64) -> Rc { + Rc::new(RevsetExpression::Descendants { + roots: self.clone(), + generation: (generations - 1)..generations, + is_legacy: false, + }) + } + /// Commits that are descendants of `self` and ancestors of `heads`, both /// inclusive. pub fn dag_range_to(