Skip to main content

Module merge

Module merge 

Source
Expand description

Delta merge: combine same-named DB/Loc tables by row identity instead of blindly concatenating every row.

The plain DB::merge/Loc::merge append every source row verbatim, so two mods editing the same rows produce duplicates instead of a combined result. This module instead matches rows by their schema key column(s) (Definition::key_column_positions), and for a key shared by more than one source resolves each field individually:

  • All contributing sources agree on the value: keep it.
  • They disagree, but only one of them actually diverges from the vanilla/parent baseline: keep the one that diverges (that source is the only one that touched this field).
  • Otherwise it’s a genuine conflict (including a row that’s brand new, with different data, in more than one source, since there’s no baseline to break the tie): reported as a MergeConflict unless the caller already supplied a MergeResolution for it.

Tables with no key column can’t be matched by row identity at all, so delta merge degrades to plain concatenation for them.

Structs§

MergeCandidate
One of the candidate values for a MergeConflict.
MergeConflict
A single field that two or more sources changed in incompatible ways, needing a user decision.
MergeOptions
Configuration for a table merge.
MergeResolution
The user’s chosen value for one MergeConflict, fed back into a follow-up merge attempt.

Functions§

db_baseline
Flattens the vanilla/parent versions of a DB table (in load order) into a single baseline table, for use as the baseline argument of delta_merge_db. Returns None if the table isn’t loaded.
delta_merge_db
Delta-merges multiple DB tables of the same name into one, using baseline (the vanilla/parent version of the table, if any) to tell an intentional edit apart from an untouched row.
delta_merge_loc
Delta-merges multiple Loc tables into one. See delta_merge_db for the general behavior; Loc tables always key on their single key column.
loc_baseline
Flattens the vanilla/parent Loc tables (in load order) into a single baseline table, for use as the baseline argument of delta_merge_loc. Returns None if no Loc data is loaded.