Irmin stores are tree-like read-write stores with extended capabilities. They allow an application (or a collection of applications) to work with multiple local states, which can be forked and merged programmatically, without having to rely on a global state. In a way very similar to version control systems, Irmin local states are called branches.
There are two kinds of store in Irmin: the ones based on persistent named branches and the ones based temporary detached heads. These exist relative to a local, larger (and shared) store, and have some (shared) contents. This is exactly the same as usual version control systems, that the informed user can see as an implicit purely functional data-structure.
of_commit c is a temporary store, based on the commit c.
Temporary stores do not have stable names: instead they can be addressed using the hash of the current commit. Temporary stores are similar to Git's detached heads. In a temporary store, all the operations are performed relative to the current head and update operations can modify the current head: the current stores's head will automatically become the new head obtained after performing the update.
test_set_and_get is like test_and_set except it also returns the commit associated with updating the store with the new value if the test_and_set is successful. No commit is returned if there was no update to the store.
with_tree t k ~info f replaces atomically the subtree v under k in the store t by the contents of the tree f v, using the commit info info ().
If v = f v and allow_empty is unset (default) then, the operation is a no-op.
If v != f v and no other changes happen concurrently, f v becomes the new subtree under k. If other changes happen concurrently to that operations, the semantics depend on the value of strategy:
if strategy = `Set, use set and discard any concurrent updates to k.
if strategy = `Test_and_set (default), use test_and_set and ensure that no concurrent operations are updating k.
if strategy = `Merge, use merge and ensure that concurrent updates and merged with the values present at the beginning of the transaction.
Note: Irmin transactions provides snapshot isolation guarantees: reads and writes are isolated in every transaction, but only write conflicts are visible on commit.
watch t f calls f every time the contents of t's head is updated.
Note: even if f might skip some head updates, it will never be called concurrently: all consecutive calls to f are done in sequence, so we ensure that the previous one ended before calling the next one.
merge_into ~into:x ~info:i t merges t's current branch into x's current branch using the info i. After that operation, the two stores are still independent. Similar to git merge <branch>.
history ?depth ?min ?max t is a view of the history of the store t, of depth at most depth, starting from the t's head (or from max if the head is not set) and stopping at min if specified.
val last_modified : ?depth:int ->?n:int ->t->path->commit listLwt.t
last_modified ?number c k is the list of the last number commits that modified path, in ascending order of date. depth is the maximum depth to be explored in the commit graph, if any. Default value for number is 1.
val integrity_check :
?ppf:Format.formatter->?heads:commit list->auto_repair:bool ->repo->([> `Fixed of int| `No_error ],
[> `Cannot_fix of string| `Corrupted of int ])resultLwt.t
Checks the integrity of the repository. if auto_repair is true, will also try to fix the issues. ppf is a formatter for progressive reporting. `Fixed and `Corrupted report the number of fixed/corrupted entries.
val integrity_check_inodes :
?heads:commit list->repo->([> `No_error ], [> `Cannot_fix of string ])resultLwt.t
val traverse_pack_file :
[ `Reconstruct_index of [ `In_place | `Output of string ]| `Check_index| `Check_and_fix_index ]->Irmin.config->
unit
val test_traverse_pack_file :
[ `Reconstruct_index of [ `In_place | `Output of string ]| `Check_index| `Check_and_fix_index ]->Irmin.config->
unit
create_one_commit_store t key path creates a new store at path from the existing one, containing only one commit, specified by the key. Note that this operation is blocking.
It requires that the files existing on disk when the operation is launched, remain on disk until the operation completes. In particular, a Gc running in a different process could remove files from disk.