-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use gitoxide for merging trees #5411
Changes from all commits
6997980
e807141
7327a57
4c8d270
e4079e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use gitbutler_oplog::entry::{OperationKind, SnapshotDetails}; | |
use gitbutler_oplog::{OplogExt, SnapshotExt}; | ||
use gitbutler_project::Project; | ||
use gitbutler_reference::normalize_branch_name; | ||
use gitbutler_repo::GixRepositoryExt; | ||
use gitbutler_repo_actions::RepoActionsExt; | ||
use gitbutler_stack::{ | ||
CommitOrChangeId, ForgeIdentifier, PatchReference, PatchReferenceUpdate, Series, | ||
|
@@ -191,14 +192,20 @@ pub fn push_stack(project: &Project, branch_id: StackId, with_force: bool) -> Re | |
|
||
// First fetch, because we dont want to push integrated series | ||
ctx.fetch(&default_target.push_remote_name(), None)?; | ||
let check_commit = IsCommitIntegrated::new(ctx, &default_target)?; | ||
let gix_repo = ctx | ||
.gix_repository()? | ||
.for_tree_diffing()? | ||
.with_object_memory(); | ||
let cache = gix_repo.commit_graph_if_enabled()?; | ||
let mut graph = gix_repo.revision_graph(cache.as_ref()); | ||
let mut check_commit = IsCommitIntegrated::new(ctx, &default_target, &gix_repo, &mut graph)?; | ||
let stack_series = stack.list_series(ctx)?; | ||
for series in stack_series { | ||
if series.head.target == merge_base { | ||
// Nothing to push for this one | ||
continue; | ||
} | ||
if series_integrated(&check_commit, &series)? { | ||
if series_integrated(&mut check_commit, &series)? { | ||
// Already integrated, nothing to push | ||
continue; | ||
} | ||
|
@@ -214,7 +221,7 @@ pub fn push_stack(project: &Project, branch_id: StackId, with_force: bool) -> Re | |
Ok(()) | ||
} | ||
|
||
fn series_integrated(check_commit: &IsCommitIntegrated, series: &Series) -> Result<bool> { | ||
fn series_integrated(check_commit: &mut IsCommitIntegrated, series: &Series) -> Result<bool> { | ||
let mut is_integrated = false; | ||
for commit in series.clone().local_commits.iter().rev() { | ||
if !is_integrated { | ||
|
@@ -226,12 +233,14 @@ fn series_integrated(check_commit: &IsCommitIntegrated, series: &Series) -> Resu | |
|
||
/// Returns the stack series for the API. | ||
/// Newest first, oldest last in the list | ||
/// `commits` is used to accelerate the is-integrated check. | ||
pub(crate) fn stack_series( | ||
ctx: &CommandContext, | ||
branch: &mut Stack, | ||
default_target: &Target, | ||
check_commit: &IsCommitIntegrated, | ||
check_commit: &mut IsCommitIntegrated, | ||
remote_commit_data: HashMap<CommitData, git2::Oid>, | ||
commits: &[VirtualBranchCommit], | ||
) -> Result<(Vec<PatchSeries>, bool)> { | ||
let mut requires_force = false; | ||
let mut api_series: Vec<PatchSeries> = vec![]; | ||
|
@@ -248,7 +257,10 @@ pub(crate) fn stack_series( | |
// Reverse first instead of later, so that we catch the first integrated commit | ||
for commit in series.clone().local_commits.iter().rev() { | ||
if !is_integrated { | ||
is_integrated = check_commit.is_integrated(commit)?; | ||
is_integrated = commits | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to save time and be reasonable in comparison to what it was before. However, since the stack can have its own remote I am not sure if the |
||
.iter() | ||
.find_map(|c| (c.id == commit.id()).then_some(Ok(c.is_integrated))) | ||
.unwrap_or_else(|| check_commit.is_integrated(commit))?; | ||
} | ||
let copied_from_remote_id = CommitData::try_from(commit) | ||
.ok() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,9 +131,7 @@ pub fn get_applied_status_cached( | |
.filter_map(|claimed_hunk| { | ||
// if any of the current hunks intersects with the owned hunk, we want to keep it | ||
for (i, git_diff_hunk) in git_diff_hunks.iter().enumerate() { | ||
if claimed_hunk == &Hunk::from(git_diff_hunk) | ||
|| claimed_hunk.intersects(git_diff_hunk) | ||
{ | ||
if claimed_hunk.intersects(git_diff_hunk) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please double-check this logic. I think it's the same as before, but avoids a ton of hashing that would happen otherwise and slow things down to a crawl. |
||
let hash = Hunk::hash_diff(&git_diff_hunk.diff_lines); | ||
if locks.contains_key(&hash) { | ||
return None; // Defer allocation to unclaimed hunks processing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this is probably fine - but the commits that are passed in here, are something deprecated that I plan to remove asap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking forward to seeing that work only done once, and what I understood is that
stack_series
is the new version, and I was basically altering the old one. The few changes I made should be easy to port to be internal tostack_series()
(if this is what's needed).