Implement Entry::mergeEntries() function for merging disparate database entries #4
+433
−0
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.
Summary
Implements a new backend feature to merge two disparate entries in the KeePassXC database into a single entry. The function combines their fields with comprehensive conflict resolution, ensuring no data is lost during the merge process.
Implementation Details
Core Function
Entry::mergeEntries(const Entry* entry1, const Entry* entry2): Static method that returns a new merged Entry objectConflict Resolution Strategy
Standard Attributes (Title, Username, Password, URL, Notes)
Merge_Conflict_<Field>_2)Custom Attributes & Attachments
CustomField_2,file_2.txt)Tags, History & Metadata
Example Usage
Testing
Comprehensive unit tests added to
TestEntry.cpp:testMergeEntries(): Basic merge functionality with tags and custom attributestestMergeEntriesConflicts(): Custom attribute conflict resolutiontestMergeEntriesAttachments(): Attachment merging with name conflictstestMergeEntriesNullInput(): Null input edge casesAll tests pass successfully, validating the merge logic handles various scenarios correctly.
Code Quality
clang-formatand translations updated withlupdateThis implementation provides a robust foundation for entry merging that could later be exposed through CLI commands or GUI features while ensuring complete data preservation.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.