package plebeia

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

Version control

Version control

type t = {
  1. vc : Vc.t;
  2. enc : Fs_nameenc.t;
}

Type of version controller

val create : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?lock:bool -> ?resize_step_bytes:int -> ?auto_flush_seconds:int -> Context.config -> Fs_nameenc.t -> string -> (t, Error.t) result Lwt.t

Create an empty commit store

val open_existing_for_read : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> Context.config -> Fs_nameenc.t -> string -> (t, Error.t) result Lwt.t

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

val open_for_write : ?hashcons:Hashcons.config -> ?node_cache:Index.t Node_cache.t -> ?resize_step_bytes:int -> ?auto_flush_seconds:int -> Context.config -> Fs_nameenc.t -> string -> (t, Error.t) result Lwt.t
val close : t -> (unit, Error.t) result Lwt.t

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

val empty : t -> Fs_tree.tree

Returns an empty tree

val of_value : t -> Value.t -> Fs_tree.tree

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

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

Checkout the commit of the given commit hash

val checkout' : t -> Commit_hash.t -> (Commit.t * Fs_tree.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 -> Fs_tree.tree -> Fs_tree.tree * 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) Fs_tree.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