From ad1ee2d1d2a7c97b771f90a320668e27fd025b77 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Mon, 15 Apr 2024 21:46:51 -0700 Subject: [PATCH] rewrite: pass root commits into `find_descendants_to_rebase()` I'm going to add another caller that wants to rebase from given roots instead. --- lib/src/repo.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/src/repo.rs b/lib/src/repo.rs index bfb70a119..d136babbf 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -1106,16 +1106,18 @@ impl MutableRepo { self.set_view(view); } - /// Find descendants of commits in `parent_mapping` and then return them in + /// Find descendants of `root`, unless they've already been rewritten + /// (according to `parent_mapping`), and then return them in /// an order they should be rebased in. The result is in reverse order /// so the next value can be removed from the end. - fn find_descendants_to_rebase(&self) -> BackendResult> { + fn find_descendants_to_rebase(&self, roots: Vec) -> BackendResult> { let store = self.store(); - let old_commits_expression = - RevsetExpression::commits(self.parent_mapping.keys().cloned().collect()); - let to_visit_expression = old_commits_expression - .descendants() - .minus(&old_commits_expression); + let to_visit_expression = + RevsetExpression::commits(roots) + .descendants() + .minus(&RevsetExpression::commits( + self.parent_mapping.keys().cloned().collect(), + )); let to_visit_revset = to_visit_expression .evaluate_programmatic(self) .map_err(|err| match err { @@ -1164,7 +1166,8 @@ impl MutableRepo { return Ok(None); } - let to_visit = self.find_descendants_to_rebase()?; + let to_visit = + self.find_descendants_to_rebase(self.parent_mapping.keys().cloned().collect())?; let mut rebaser = DescendantRebaser::new(settings, self, to_visit); *rebaser.mut_options() = options; rebaser.rebase_all()?;