CommitStateBuilder¶
- class dsviper.CommitStateBuilder¶
Bases:
objectReconstructs a CommitState from a chosen commit.
state(commit_database, commit_id), initial_state(commit_database), merge_state(commit_database, ours, theirs). Stateless: every method takes the database as its first argument.
Note: Not directly instantiable.
- static enabled_by_commit_id(commit_database: CommitDatabase, commit_id: ValueCommitId) dict[ValueCommitId, bool]¶
Return which commits of commit_database are enabled at the commit commit_id names, as a dict[ValueCommitId, bool].
- static initial_state(commit_database: CommitDatabase) CommitState¶
Return the state of commit_database before its first commit.
Every attachment is empty, typed by its definitions. This is where a sequence STARTS, and only there. Coming back to it on a database that already holds commits builds the next one from the root again, which diverges into a second head: use state() with the commit_id the last commit_mutations returned to carry on instead.
- static merge_enabled_by_commit_id(commit_database: CommitDatabase, ours: ValueCommitId, theirs: ValueCommitId) dict[ValueCommitId, bool]¶
Return the enabled/disabled dict[ValueCommitId, bool] that reducing ours and theirs in commit_database would produce, for the virtual merge of (ours, theirs), without persisting a merge commit.
- static merge_state(commit_database: CommitDatabase, ours: ValueCommitId, theirs: ValueCommitId) CommitState¶
Return the state reducing ours and theirs would produce.
Computed over commit_database, without persisting a merge commit.
Value-identical to state(merge_commit(ours, theirs)).
- static state(commit_database: CommitDatabase, commit_id: ValueCommitId) CommitState¶
Return the state commit_database reaches at the commit commit_id names.
It evaluates every commit down to it. This is how a sequence CARRIES ON: hand it the commit_id that commit_mutations returned and the next mutation continues the same line, where initial_state would start a second one. CommitStore keeps that thread for you, if you would rather not hold it yourself.
ValueCommitId.INVALID is the one id naming no commit that this accepts, and it answers what initial_state does. It names the root CommitNode.build() shows, which stands for the state before the first commit; commit_header raises on that same id, having no header to return.