DatabaseToCommitDatabaseConverter

class dsviper.DatabaseToCommitDatabaseConverter

Bases: object

Brings a flat Database under version control.

The whole source state becomes one commit, under a label you give. Only the blobs the documents reference are carried over.

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 convert() 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 conversion wrote, held by the object that wrote it - which is why a second convert() raises, leaving both databases untouched.

convert(source: Database, target: CommitDatabase, label: str, progress: StepperDelegate | None = None) → DatabaseTransferInfo

Convert source into target, a CommitDatabase, as a single commit labelled label. progress is an optional StepperDelegate. Return a DatabaseTransferInfo.