mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
repo: add parents of abandoned commit to parent_mapping
By adding the abandoned commit's parents to `parent_mapping`, we can remove a bit more of the special handling of abandoned commitsin `DescendantRebaser`.
This commit is contained in:
parent
1587aaa34d
commit
3ddf9f4329
2 changed files with 7 additions and 8 deletions
|
@ -857,9 +857,15 @@ impl MutableRepo {
|
|||
/// The `rebase_descendants` logic will rebase the descendants of `old_id`
|
||||
/// to become the descendants of parent(s) of `old_id`. Any branches at
|
||||
/// `old_id` would be moved to the parent(s) of `old_id` as well.
|
||||
// TODO: Propagate errors from commit lookup or take a Commit as argument.
|
||||
pub fn record_abandoned_commit(&mut self, old_id: CommitId) {
|
||||
assert_ne!(old_id, *self.store().root_commit_id());
|
||||
self.abandoned.insert(old_id);
|
||||
self.divergent.remove(&old_id);
|
||||
self.abandoned.insert(old_id.clone());
|
||||
// Descendants should be rebased onto the commit's parents
|
||||
let old_commit = self.store().get_commit(&old_id).unwrap();
|
||||
self.parent_mapping
|
||||
.insert(old_id, old_commit.parent_ids().to_vec());
|
||||
}
|
||||
|
||||
fn clear_descendant_rebaser_plans(&mut self) {
|
||||
|
|
|
@ -540,13 +540,6 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
|
|||
}
|
||||
let old_parent_ids = old_commit.parent_ids();
|
||||
let new_parent_ids = self.new_parents(old_parent_ids);
|
||||
if self.mut_repo.abandoned.contains(&old_commit_id) {
|
||||
// Update the `new_parents` map so descendants are rebased correctly.
|
||||
self.mut_repo
|
||||
.parent_mapping
|
||||
.insert(old_commit_id.clone(), new_parent_ids.clone());
|
||||
return Ok(());
|
||||
}
|
||||
if new_parent_ids == old_parent_ids {
|
||||
// The commit is already in place.
|
||||
return Ok(());
|
||||
|
|
Loading…
Reference in a new issue