Skip to content

Commit

Permalink
rewrite.rs DescendantRebaser: rename variable for clarity
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
ilyagr committed Jan 31, 2024
1 parent 96d0e77 commit 9b39504
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/src/rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,10 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
&mut self,
old_commit_id: CommitId,
new_commit_ids: Vec<CommitId>,
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![];
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9b39504

Please sign in to comment.