From 9b39504df7df25ae4f031bcc1f7f0607263ec84d Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 30 Jan 2024 18:30:33 -0800 Subject: [PATCH] rewrite.rs DescendantRebaser: rename variable for clarity The `edit` argument seems to be true if and only if the old commit was *not* abandoned. So, I flipped its value and renamed it to `old_commit_was_abanoned`. --- lib/src/rewrite.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index f5e61e4f5cf..32d077a0915 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -456,10 +456,10 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { &mut self, old_commit_id: CommitId, new_commit_ids: Vec, - edit: bool, + abandoned_old_commit: bool, ) -> Result<(), BackendError> { // We arbitrarily pick a new working-copy commit among the candidates. - self.update_wc_commits(&old_commit_id, &new_commit_ids[0], edit)?; + self.update_wc_commits(&old_commit_id, &new_commit_ids[0], abandoned_old_commit)?; if let Some(branch_names) = self.branches.get(&old_commit_id).cloned() { let mut branch_updates = vec![]; @@ -496,7 +496,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { &mut self, old_commit_id: &CommitId, new_commit_id: &CommitId, - edit: bool, + abandoned_old_commit: bool, ) -> Result<(), BackendError> { let workspaces_to_update = self .mut_repo @@ -507,7 +507,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { } let new_commit = self.mut_repo.store().get_commit(new_commit_id)?; - let new_wc_commit = if edit { + let new_wc_commit = if !abandoned_old_commit { new_commit } else { self.mut_repo @@ -534,13 +534,13 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { // (i.e. it's part of the input for this rebase). We don't need // to rebase it, but we still want to update branches pointing // to the old commit. - self.update_references(old_commit_id, new_parent_ids, true)?; + self.update_references(old_commit_id, new_parent_ids, false)?; continue; } if let Some(divergent_ids) = self.divergent.get(&old_commit_id).cloned() { // Leave divergent commits in place. Don't update `parent_mapping` since we // don't want to rebase descendants either. - self.update_references(old_commit_id, divergent_ids, true)?; + self.update_references(old_commit_id, divergent_ids, false)?; continue; } let old_parent_ids = old_commit.parent_ids(); @@ -549,7 +549,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { // Update the `new_parents` map so descendants are rebased correctly. self.parent_mapping .insert(old_commit_id.clone(), new_parent_ids.clone()); - self.update_references(old_commit_id, new_parent_ids, false)?; + self.update_references(old_commit_id, new_parent_ids, true)?; continue; } else if new_parent_ids == old_parent_ids { // The commit is already in place. @@ -586,7 +586,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> { (None, None), "Trying to rebase the same commit {old_commit_id:?} in two different ways", ); - self.update_references(old_commit_id, vec![new_commit.id().clone()], true)?; + self.update_references(old_commit_id, vec![new_commit.id().clone()], false)?; return Ok(Some(RebasedDescendant { old_commit, new_commit,