From 21fb2fd30c0bcbc85bd8f915d9e349f2d59bf2c8 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 28 Jun 2025 21:03:12 +0900 Subject: [PATCH] rewrite: deduplicate internal parents while collecting transitive edges In merge-heavy history, the size of collected transitive parents can easily explode. I simply changed the data type to IndexSet as we use IndexSet for the mapping of external parents. Fixes #6850 --- lib/src/rewrite.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/rewrite.rs b/lib/src/rewrite.rs index 7cd6fd560..f7eec17cf 100644 --- a/lib/src/rewrite.rs +++ b/lib/src/rewrite.rs @@ -475,7 +475,7 @@ pub fn compute_move_commits( ) -> BackendResult { let target_commit_ids: IndexSet; let connected_target_commits: Vec; - let connected_target_commits_internal_parents: HashMap>; + let connected_target_commits_internal_parents: HashMap>; let target_roots: HashSet; match &loc.target { @@ -1030,15 +1030,15 @@ pub fn duplicate_commits_onto_parents( fn compute_internal_parents_within( target_commit_ids: &IndexSet, graph_commits: &[Commit], -) -> HashMap> { - let mut internal_parents: HashMap> = HashMap::new(); +) -> HashMap> { + let mut internal_parents: HashMap> = HashMap::new(); for commit in graph_commits.iter().rev() { // The roots of the set will not have any parents found in `internal_parents`, // and will be stored as an empty vector. - let mut new_parents = vec![]; + let mut new_parents = IndexSet::new(); for old_parent in commit.parent_ids() { if target_commit_ids.contains(old_parent) { - new_parents.push(old_parent.clone()); + new_parents.insert(old_parent.clone()); } else if let Some(parents) = internal_parents.get(old_parent) { new_parents.extend(parents.iter().cloned()); }