package datakit-client

  1. Overview
  2. Docs
type t

A t is a named pointer to a commit.

val name : t -> string

name t is t's name.

val remove : t -> unit or_error Lwt.t

remove t deletes branch t. If t does not exist, this does nothing.

val rename : t -> string -> unit or_error Lwt.t

rename t new_name changes the name of this branch. It is an error if new_name already exists.

val head : t -> Commit.t option or_error Lwt.t

head t is the current head of the branch, or None if it doesn't currently exist.

val wait_for_head : t -> ?switch:Lwt_switch.t -> (Commit.t option -> [ `Finish of 'a | `Again | `Abort ] or_error Lwt.t) -> [ `Abort | `Finish of 'a ] or_error Lwt.t

wait_for_head t fn calls fn commit on the current commit. If it returns `Again then it waits for the commit to change and tries again. If switch is provided, then turning off the switch will make the wait return `Abort at the next opportunity.

val wait_for_path : t -> ?switch:Lwt_switch.t -> Datakit_path.t -> ([ `File of Cstruct.t | `Dir of Tree.t | `Link of string | `Exec of Cstruct.t ] option -> [ `Finish of 'a | `Again | `Abort ] or_error Lwt.t) -> [ `Abort | `Finish of 'a ] or_error Lwt.t

wait_for_path is similar to wait_for_head, but waits for a particular sub-tree to change.

val fast_forward : t -> Commit.t -> unit or_error Lwt.t

fast_forward t commit changes t to point to commit if t's head is an ancestor of commit (or returns an error if not).

val with_transaction : t -> (Transaction.t -> 'a or_error Lwt.t) -> 'a or_error Lwt.t

with_transaction t fn is the result of applying fn to a new transaction on branch t. If the transaction has not been committed when fn trans returns, the transaction is aborted (and a warning is logged). Use Transaction.abort to avoid the warning.

val transaction : t -> Transaction.t or_error Lwt.t

transaction t creates a new transaction on top of the branch t. Must be closed with Transaction.abort or Transaction.commit. Use with_transaction to not have to worry about resource leaks..