merge method
Implementation
@override
void merge(MergeContext mergeContext, KdbxEntry other) {
assertSameUuid(other, 'merge');
if (other.wasModifiedAfter(this)) {
_logger.finest('$this has incoming changes.');
// other object is newer, create new history entry and copy fields.
modify(() => _overwriteFrom(mergeContext, other));
} else if (wasModifiedAfter(other)) {
_logger.finest('$this has outgoing changes.');
// we are newer. check if the old revision lives on in our history.
final ourLastModificationTime = times.lastModificationTime.get();
final historyEntry = _findHistoryEntry(history, ourLastModificationTime);
if (historyEntry == null) {
// it seems like we don't know about that state, so we have to add
// it to history.
history.add(other.cloneInto(parent!, toHistoryEntry: true));
}
} else {
_logger.finest('$this has no changes.');
}
// copy missing history entries.
for (final otherHistoryEntry in other.history) {
final meHistoryEntry = _findHistoryEntry(
history, otherHistoryEntry.times.lastModificationTime.get());
if (meHistoryEntry == null) {
mergeContext.trackChange(
this,
debug: 'merge in history '
'${otherHistoryEntry.times.lastModificationTime.get()}',
);
history.add(otherHistoryEntry.cloneInto(parent!, toHistoryEntry: true));
}
}
mergeContext.markAsMerged(this);
}