package plebeia

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Version control

type t = Vc.t

Type of version controller

val create : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?lock:bool -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?resize_step_bytes:int -> ?auto_flush_seconds:int -> string -> (t, Error.t) Stdlib.result Lwt.t

Create an empty commit store

val open_ : mode:Storage.mode -> ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?bytes_per_cell:int -> ?hash_func:[ `Blake2B | `Blake3 ] -> ?bytes_per_hash:int -> ?resize_step_bytes:int -> ?auto_flush_seconds:int -> string -> (t, Error.t) Stdlib.result Lwt.t

Opens a commit store of the given name if it exists. Otherwise, it creates a new store.

val close : t -> (unit, Error.t) Stdlib.result Lwt.t

Close the version control. Once closed, further uses of t are unspecified.

val empty : t -> tree

Returns an empty tree

val of_value : t -> bytes -> tree

Returns a tree of a leaf with the value specified by the given bytes

val checkout : t -> Commit_hash.t -> tree option Lwt.t

Checkout the commit of the given commit hash

val checkout' : t -> Commit_hash.t -> (Commit.t * tree) option Lwt.t

Same as checkout but returns the commit information together

val mem : t -> Commit_hash.t -> bool Lwt.t

Check the given commit hash is known

val compute_commit_hash : t -> parent:Commit_hash.t option -> cursor -> cursor * Commit_hash.t

Compute the commit hash for the root of the current tree. The tree is moved to the root.

Note that the commit hash is NOT the top Merkle hash of the tree. It is computed from the top Merkle hash and the parent commit hash

val commit : ?allow_missing_parent:bool -> t -> parent:Commit_hash.t option -> hash_override:Commit_hash.t option -> (Hash.Prefix.t * Commit.t) Op_lwt.t

Commit the contents of the tree at the root. It then returns the updated tree, the hash, and the commit information.

If override is false (by default), hash collision fails the function. If it is true, it overwrites the hash.

The commit will be persisted to the disk eventually, but may be lost if the program crashes. To make it surely persisted, flush must be called explicitly.

val flush : t -> unit Lwt.t

Synchronize the commits to the disk. Commits after the last call of this flush may be lost when the program crashes.

Too frequent call of this function may slow down the system.

val commit_db : t -> Commit_db.t

Underlying commit database

val context : t -> Context.t

Underlying context

OCaml

Innovation. Community. Security.