Skip to content
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

Implement "external" conflict resolution for merges #6631

Merged
merged 5 commits into from
Apr 25, 2023

Conversation

snazy
Copy link
Member

@snazy snazy commented Apr 19, 2023

Build on the API changes in #6619. Implements the logic for the new storage model.

@snazy snazy marked this pull request as draft April 19, 2023 13:23
@snazy snazy force-pushed the implement-ext-conflict-resolution branch 2 times, most recently from 407403a to 05ca371 Compare April 19, 2023 17:27
@snazy snazy requested a review from dimas-b April 19, 2023 17:27
@snazy snazy marked this pull request as ready for review April 19, 2023 17:27
Copy link
Member

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass with some comments (incomplete)

*/
@Nullable
@jakarta.annotation.Nullable
ObjId doCommit(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI some of the changes here overlap with changes introduced in #6647, but so far they seem compatible.

@snazy snazy force-pushed the implement-ext-conflict-resolution branch from 05ca371 to 08041b8 Compare April 21, 2023 09:51
@snazy snazy requested a review from dimas-b April 22, 2023 05:09
@snazy snazy force-pushed the implement-ext-conflict-resolution branch from 08041b8 to 1e7d033 Compare April 23, 2023 03:36
Copy link
Member

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple of comments on storing commit objects in case of conflicts (also relates to #6677)

if (mergeKeyBe.getExpectedTargetContent() == null) {
keyDetailsMap.put(key, keyDetails(mergeBehavior, ConflictType.NONE));
return mergeBehavior == MergeBehavior.FORCE
? ConflictResolution.IGNORE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe rename ConflictResolution.IGNORE to ADD for the sake of clarity? On the caller side it is not obvious that IGNORE will cause the action to be added to the commit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do in a separate PR


// It's okay to do the fetchCommit() here and not complicate the surrounding logic (think:
// local cache)
StoreIndex<CommitOp> headIndex = indexesLogic(persist).buildCompleteIndexOrEmpty(head);
verifyMergeTransplantCommitPolicies(headIndex, mergeCommit);

mergeBehaviors.postValidate();

// TODO check keyDetailsMap for conflicts here - no need to persist the merge commit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We should not call commitLogic.storeCommit() if there are conflicts (same for transplanting individual commits).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do in a separate PR (same for the comment below)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you wanna tackle it as part of #6677?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I thought so too :)


if (!indexesLogic.commitOperations(newCommit).iterator().hasNext()) {
// No operations in this commit, skip it.
continue;
}

CommitLogic commitLogic = commitLogic(persist);
boolean committed = commitLogic.storeCommit(newCommit, emptyList());
boolean committed = commitLogic.storeCommit(newCommit, objsToStore);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not call this method if/when keyDetailsMap contains conflicts.


// It's okay to do the fetchCommit() here and not complicate the surrounding logic (think:
// local cache)
StoreIndex<CommitOp> headIndex = indexesLogic(persist).buildCompleteIndexOrEmpty(head);
verifyMergeTransplantCommitPolicies(headIndex, mergeCommit);

mergeBehaviors.postValidate();

// TODO check keyDetailsMap for conflicts here - no need to persist the merge commit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@snazy snazy merged commit 1fad016 into projectnessie:main Apr 25, 2023
22 checks passed
@snazy snazy deleted the implement-ext-conflict-resolution branch April 25, 2023 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants