Three-way merge function for prolly trees - #91
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The implementation follows standard three-way merge semantics where non-conflicting changes are automatically merged, while conflicting changes are flagged with detailed information for manual resolution. All tests pass (18/18) confirming the implementation works correctly with the existing prolly tree architecture.
Merge Function:
Three-way merge algorithm that takes source, destination, and base tree root hashes
Comprehensive conflict detection for all merge scenarios
Efficient diff-based approach using existing tree comparison functionality
MergeResult::Added(key, value) - Apply addition from source branch
MergeResult::Removed(key) - Apply deletion from source branch
MergeResult::Modified(key, value) - Apply modification from source branch
MergeResult::Conflict(MergeConflict) - Conflict requiring manual resolution
Conflict Detection:
Tests:
conflicts
it
✅ Key Features
for resolution
🔍 Usage Example
let merge_tree = ProllyTree::new(storage, config);
let merge_results = merge_tree.merge(&source_root, &dest_root, &base_root);
for result in merge_results {
match result {
MergeResult::Added(key, value) => /* apply addition /,
MergeResult::Modified(key, value) => / apply modification /,
MergeResult::Removed(key) => / apply deletion /,
MergeResult::Conflict(conflict) => / handle conflict manually */,
}
}