package irmin-pack

  1. Overview
  2. Docs
On This Page
  1. Repositories
Legend:
Library
Module
Module type
Parameter
Class
Class type

Repositories.

Repositories

A repository contains a set of branches.

type t = repo

The type of repository handles.

val v : Irmin__.Conf.t -> t Lwt.t

v config connects to a repository in a backend-specific manner.

val close : t -> unit Lwt.t

close t frees up all resources associated with t. Any operations run on a closed repository will raise Closed.

val heads : t -> commit list Lwt.t

heads is Head.list.

val branches : t -> branch list Lwt.t

branches is Branch.list.

val export : ?full:bool -> ?depth:int -> ?min:commit list -> ?max:[ `Head | `Max of commit list ] -> t -> slice Lwt.t

export t ~full ~depth ~min ~max exports the store slice between min and max, using at most depth history depth (starting from the max).

If max is `Head (also the default value), use the current heads. If min is not specified, use an unbound past (but can still be limited by depth).

depth is used to limit the depth of the commit history. None here means no limitation.

If full is set (default is true), the full graph, including the commits, nodes and contents, is exported, otherwise it is the commit history graph only.

val import : t -> slice -> (unit, [ `Msg of string ]) Stdlib.result Lwt.t

import t s imports the contents of the slice s in t. Does not modify branches.

type elt = [
  1. | `Commit of hash
  2. | `Node of hash
  3. | `Contents of hash
  4. | `Branch of branch
]

The type for elements iterated over by iter.

val elt_t : elt Irmin.Type.t
val iter : ?cache_size:int -> min:elt list -> max:elt list -> ?edge:(elt -> elt -> unit Lwt.t) -> ?branch:(branch -> unit Lwt.t) -> ?commit:(hash -> unit Lwt.t) -> ?node:(hash -> unit Lwt.t) -> ?contents:(hash -> unit Lwt.t) -> ?skip_branch:(branch -> bool Lwt.t) -> ?skip_commit:(hash -> bool Lwt.t) -> ?skip_node:(hash -> bool Lwt.t) -> ?skip_contents:(hash -> bool Lwt.t) -> ?pred_branch:(t -> branch -> elt list Lwt.t) -> ?pred_commit:(t -> hash -> elt list Lwt.t) -> ?pred_node:(t -> hash -> elt list Lwt.t) -> ?pred_contents:(t -> hash -> elt list Lwt.t) -> ?rev:bool -> t -> unit Lwt.t

iter t iterates in topological order over the closure graph of t. If rev is set (by default it is) the traversal is done in reverse order.

skip_branch, skip_commit, skip_node and skip_contents allow the traversal to be stopped when the corresponding objects are traversed. By default no objects are skipped.

The branch, commit, node and contents functions are called whenever the corresponding objects are traversed. By default these functions do nothing. These functions are not called on skipped objects.

pred_branch, pred_commit, pred_node and pred_contents implicitly define the graph underlying the traversal. By default they exactly match the underlying Merkle graph of the repository t. These functions can be used to traverse a slightly modified version of that graph, for instance by modifying pred_contents to implicitly link structured contents with other objects in the graph.

The traversed objects are all included between min (included) and max (included), following the Merkle graph order. Moreover, the min boundary is extended as follows:

  • contents and node objects in min stop the traversal; their predecessors are not traversed.
  • commit objects in min stop the traversal for their commit predecessors, but their sub-node are still traversed. This allows users to define an inclusive range of commit to iterate over.
  • branch objects in min implicitly add to min the commit they are pointing to; this allow users to define the iteration between two branches.

cache_size is the size of the LRU used to store traversed objects. If an entry is evicted from the LRU, it can be traversed multiple times by Repo.iter. When cache_size is None (the default), no entries is ever evicted from the cache; hence every object is only traversed once, at the cost of having to store all the traversed objects in memory.

OCaml

Innovation. Community. Security.