Part of bzrlib
Transactions provide hooks to allow data objects (i.e. inventory weaves or the revision-history file) to be placed in a registry and retrieved later during the same transaction. Transactions in bzr are not atomic - they depend on data ordering of writes, so we do not have commit or rollback facilities at the transaction level.
Read only transactions raise an assert when objects are listed as dirty against them - preventing unintended writes.
Write transactions preserve dirty objects in the cache, though due to the write ordering approach we use for consistency 'dirty' is a misleading term. A dirty object is one we have modified.
Both read and write transactions may flush unchanged objects out of memory, unless they are marked as 'precious' which indicates that repeated reads cannot be obtained if the object is ejected, or that the object is an expensive one for obtaining.