CommitDatabaseFlattener¶
- class dsviper.CommitDatabaseFlattener¶
Bases:
objectCollapses one chosen commit into a single commit in another CommitDatabase.
History and superseded blobs are discarded; the state is kept. It opens an exclusive transaction of its own.
The target is a database you have just created: these transfers write into an empty one, and nothing checks it for you. The commit it writes is a root: it has no parent, so it continues nothing the target may already hold.
A run that raises part-way does not undo what it has already written. Every blob is copied inside one exclusive transaction, committed before the first document: a failure among them leaves none behind, a failure after them leaves them all, referenced by no commit. The documents are held in memory until the single commit is written. commit_id() answers None either way. Discard the target and start again.
- commit_id() ValueCommitId | None¶
Return the commit flatten() made, or None before it ran.
Reading the target’s heads instead would race: the write is over, so another stream may have added one. This is the id the flattening wrote, held by the object that wrote it - which is why a second flatten() raises, leaving both databases untouched.
- flatten(source: CommitDatabase, commit_id: ValueCommitId, target: CommitDatabase, label: str, progress: StepperDelegate | None = None) DatabaseTransferInfo¶
Write the state of commit_id from source into target as one root commit labelled label; the history is not carried. progress is an optional StepperDelegate. Return a DatabaseTransferInfo.