mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-28 23:32:41 +00:00
git: scan new commits all at once from multiple heads
The visiting order is DFS from heads sorted in lexicographical order, but I plan to change it to chronological order.
This commit is contained in:
parent
73a4b7f5bf
commit
7ddced7f3f
1 changed files with 9 additions and 5 deletions
|
@ -214,7 +214,8 @@ pub fn import_some_refs(
|
||||||
let changed_git_refs = diff_refs_to_import(mut_repo.view(), git_repo, git_ref_filter)?;
|
let changed_git_refs = diff_refs_to_import(mut_repo.view(), git_repo, git_ref_filter)?;
|
||||||
|
|
||||||
// Import new heads
|
// Import new heads
|
||||||
let store = mut_repo.store().clone();
|
let store = mut_repo.store();
|
||||||
|
let mut head_commits = Vec::new();
|
||||||
if let Some(new_head_target) = &changed_git_head {
|
if let Some(new_head_target) = &changed_git_head {
|
||||||
for id in new_head_target.added_ids() {
|
for id in new_head_target.added_ids() {
|
||||||
let commit = store
|
let commit = store
|
||||||
|
@ -223,8 +224,7 @@ pub fn import_some_refs(
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
err,
|
err,
|
||||||
})?;
|
})?;
|
||||||
prevent_gc(git_repo, id)?;
|
head_commits.push(commit);
|
||||||
mut_repo.add_head(&commit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (ref_name, (_, new_git_target)) in &changed_git_refs {
|
for (ref_name, (_, new_git_target)) in &changed_git_refs {
|
||||||
|
@ -236,10 +236,14 @@ pub fn import_some_refs(
|
||||||
ref_name: ref_name.to_string(),
|
ref_name: ref_name.to_string(),
|
||||||
err,
|
err,
|
||||||
})?;
|
})?;
|
||||||
prevent_gc(git_repo, id)?;
|
head_commits.push(commit);
|
||||||
mut_repo.add_head(&commit);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for commit in &head_commits {
|
||||||
|
prevent_gc(git_repo, commit.id())?;
|
||||||
|
}
|
||||||
|
head_commits.reverse(); // TODO: sort chronologically by add_heads()
|
||||||
|
mut_repo.add_heads(&head_commits);
|
||||||
|
|
||||||
// Apply the change that happened in git since last time we imported refs.
|
// Apply the change that happened in git since last time we imported refs.
|
||||||
if let Some(new_head_target) = changed_git_head {
|
if let Some(new_head_target) = changed_git_head {
|
||||||
|
|
Loading…
Reference in a new issue