CommitMergeAnalyzer

class dsviper.CommitMergeAnalyzer

Bases: object

Additive analysis and supervised correction over a CommitDatabase, before or after the merge commit is written. Static methods only; the Commit Engine itself is not modified.

It works around the reduction; it does not repair it. The engine has no notion of conflict, so what this class calls a conflict is reconstructed after the fact, by comparing the two heads against what the merge produced.

Note: Not directly instantiable.

static analyze_merge(db: CommitDatabase, merge_commit: ValueCommitId) → CommitMergeAnalysis

Read the state of merge_commit in db and return a CommitMergeAnalysis: the loci where one head’s intent did not survive the merge. 3-way when a unique structural base exists, base-free 2-way fallback otherwise. Raises when merge_commit is not a merge commit.

static analyze_virtual_merge(db: CommitDatabase, ours: ValueCommitId, theirs: ValueCommitId) → CommitMergeAnalysis

Pre-merge analysis over db, without persisting a merge commit.

The same classification runs against the merge state that reducing (ours, theirs) would produce.

The loci are reconstructed against a merge that does not exist yet and may never be written, so the result’s merge_commit() is None. Its resolutions feed materialize_merge over the same (ours, theirs), in the same order, or reconcile once that merge is written: the merge of the reversed pair keeps the other side.

static materialize_merge(db: CommitDatabase, ours: ValueCommitId, theirs: ValueCommitId, resolutions: list[CommitMergeResolution], merge_label: str, survival_label: str) → tuple[ValueCommitId, ValueCommitId]

Pre-merge materialization in db.

Writes the Merge join of (ours, theirs) under merge_label, then the survival commit of resolutions against it under survival_label.

Returns (merge_commit, survival); survival == merge_commit when every decree accepts the merge. Raises before writing anything when a resolution was analysed against another (ours, theirs), the reversed pair included.

static merge_base(db: CommitDatabase, a: ValueCommitId, b: ValueCommitId) → ValueCommitId | None

Return the structural merge base of a and b in db, or None when there is no common ancestor or several maximal common ancestors (criss-cross).

static reconcile(db: CommitDatabase, merge_commit: ValueCommitId, resolutions: list[CommitMergeResolution], label: str) → ValueCommitId

Author the survival commit for merge_commit in db under label.

Per document, copy the merge state, place each decree of resolutions at its path, then diff against the merge state. Returns a Mutations commit child of merge_commit, or merge_commit itself when every decree accepts the merge (no surviving opcode).

Raises, writing nothing, when merge_commit is not a merge commit, or when a resolution was analysed against another (ours, theirs) than the one merge_commit joins. The survival commit is a child of merge_commit whatever came after it: on a merge that already has descendants, it is one more head.

static reconcile_state(merge_state: CommitState, resolutions: list[CommitMergeResolution]) → CommitMutableState

Compose the resolutions into a working state, writing no commit.

Per document, copy merge_state, place each decree of resolutions at its path, diff into a CommitMutableState. The returned state is what a UI renders and edits live. reconcile is this followed by commit_mutations, over a MATERIALIZED merge and only there.

Given a virtual merge state, from merge_state or the analysis analyze_virtual_merge returns, committing the result writes a Mutations commit on ONE parent: the two heads stay and a third appears, where a merge would have left one. Use materialize_merge, which writes the join and the survival commit in order.