forked from mirrors/jj
rewrite: pass old parent ids in to mut_repo.new_parents() by slice
This commit is contained in:
parent
1fe9422a6e
commit
d99a8508e4
3 changed files with 8 additions and 11 deletions
|
@ -113,7 +113,7 @@ pub(crate) fn cmd_parallelize(
|
|||
// Commits in the target set do not depend on each other but they still depend
|
||||
// on other parents
|
||||
if let Some(new_parents) = new_target_parents.get(rewriter.old_commit().id()) {
|
||||
rewriter.set_new_rewritten_parents(new_parents.clone());
|
||||
rewriter.set_new_rewritten_parents(new_parents);
|
||||
} else if rewriter
|
||||
.old_commit()
|
||||
.parent_ids()
|
||||
|
@ -128,7 +128,7 @@ pub(crate) fn cmd_parallelize(
|
|||
new_parents.push(parent.clone());
|
||||
}
|
||||
}
|
||||
rewriter.set_new_rewritten_parents(new_parents);
|
||||
rewriter.set_new_rewritten_parents(&new_parents);
|
||||
}
|
||||
if rewriter.parents_changed() {
|
||||
let builder = rewriter.rebase(command.settings())?;
|
||||
|
|
|
@ -989,7 +989,7 @@ impl MutableRepo {
|
|||
///
|
||||
/// If `parent_mapping` contains cycles, this function may either panic or
|
||||
/// drop parents that caused cycles.
|
||||
pub fn new_parents(&self, old_ids: Vec<CommitId>) -> Vec<CommitId> {
|
||||
pub fn new_parents(&self, old_ids: &[CommitId]) -> Vec<CommitId> {
|
||||
assert!(!old_ids.is_empty());
|
||||
let mut new_ids = Vec::with_capacity(old_ids.len());
|
||||
let mut to_visit = old_ids.iter().rev().collect_vec();
|
||||
|
@ -1040,7 +1040,7 @@ impl MutableRepo {
|
|||
// mappings, not transitive ones.
|
||||
// TODO: keep parent_mapping updated with transitive mappings so we don't need
|
||||
// to call `new_parents()` here.
|
||||
let new_parent_ids = self.new_parents(rewrite.new_parent_ids().to_vec());
|
||||
let new_parent_ids = self.new_parents(rewrite.new_parent_ids());
|
||||
self.update_references(settings, old_parent_id, new_parent_ids)?;
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1226,7 +1226,7 @@ impl MutableRepo {
|
|||
) -> BackendResult<()> {
|
||||
let mut to_visit = self.find_descendants_to_rebase(roots)?;
|
||||
while let Some(old_commit) = to_visit.pop() {
|
||||
let new_parent_ids = self.new_parents(old_commit.parent_ids().to_vec());
|
||||
let new_parent_ids = self.new_parents(old_commit.parent_ids());
|
||||
let rewriter = CommitRewriter::new(self, old_commit, new_parent_ids);
|
||||
callback(rewriter)?;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ impl<'repo> CommitRewriter<'repo> {
|
|||
|
||||
/// Set the old commit's intended new parents to be the rewritten versions
|
||||
/// of the given parents.
|
||||
pub fn set_new_rewritten_parents(&mut self, unrewritten_parents: Vec<CommitId>) {
|
||||
pub fn set_new_rewritten_parents(&mut self, unrewritten_parents: &[CommitId]) {
|
||||
self.new_parents = self.mut_repo.new_parents(unrewritten_parents);
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ impl<'settings, 'repo> DescendantRebaser<'settings, 'repo> {
|
|||
fn rebase_one(&mut self, old_commit: Commit) -> BackendResult<()> {
|
||||
let old_commit_id = old_commit.id().clone();
|
||||
let old_parent_ids = old_commit.parent_ids();
|
||||
let new_parent_ids = self.mut_repo.new_parents(old_parent_ids.to_vec());
|
||||
let new_parent_ids = self.mut_repo.new_parents(old_parent_ids);
|
||||
let rewriter = CommitRewriter::new(self.mut_repo, old_commit, new_parent_ids);
|
||||
if !rewriter.parents_changed() {
|
||||
// The commit is already in place.
|
||||
|
@ -806,10 +806,7 @@ pub fn move_commits(
|
|||
// tests.
|
||||
while let Some(old_commit_id) = to_visit.pop() {
|
||||
let old_commit = to_visit_commits.get(&old_commit_id).unwrap();
|
||||
let parent_ids = to_visit_commits_new_parents
|
||||
.get(&old_commit_id)
|
||||
.cloned()
|
||||
.unwrap();
|
||||
let parent_ids = to_visit_commits_new_parents.get(&old_commit_id).unwrap();
|
||||
let new_parent_ids = mut_repo.new_parents(parent_ids);
|
||||
let rewriter = CommitRewriter::new(mut_repo, old_commit.clone(), new_parent_ids);
|
||||
if rewriter.parents_changed() {
|
||||
|
|
Loading…
Reference in a new issue