Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file commit_intf.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207(*
* Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openSopen!ImportmoduletypeS=sig(** {1 Commit values} *)typet(** The type for commit values. *)typehash(** Type for keys. *)valv:info:Info.t->node:hash->parents:hashlist->t(** Create a commit. *)valnode:t->hash(** The underlying node. *)valparents:t->hashlist(** The commit parents. *)valinfo:t->Info.t(** The commit info. *)(** {1 Value Types} *)valt:tType.t(** [t] is the value type for {!t}. *)valhash_t:hashType.t(** [hash_t] is the value type for {!hash}. *)endmoduletypeSTORE=sig(** {1 Commit Store} *)includeCONTENT_ADDRESSABLE_STOREvalmerge:[>read_write]t->info:Info.f->keyoptionMerge.t(** [merge] is the 3-way merge function for commit keys. *)(** [Key] provides base functions for commit keys. *)moduleKey:Hash.TYPEDwithtypet=keyandtypevalue=value(** [Val] provides functions for commit values. *)moduleVal:Swithtypet=valueandtypehash=keymoduleNode:Node.STOREwithtypekey=Val.hash(** [Node] is the underlying node store. *)endmoduletypeHISTORY=sig(** {1 Commit History} *)type'at(** The type for store handles. *)typenode(** The type for node values. *)typecommit(** The type for commit values. *)typev(** The type for commit objects. *)valv:[>write]t->node:node->parents:commitlist->info:Info.t->(commit*v)Lwt.t(** Create a new commit. *)valparents:[>read]t->commit->commitlistLwt.t(** Get the commit parents.
Commits form a append-only, fully functional, partial-order
data-structure: every commit carries the list of its immediate
predecessors. *)valmerge:[>read_write]t->info:Info.f->commitMerge.t(** [merge t] is the 3-way merge function for commit. *)vallcas:[>read]t->?max_depth:int->?n:int->commit->commit->(commitlist,[`Max_depth_reached|`Too_many_lcas])resultLwt.t(** Find the lowest common ancestors
{{:http://en.wikipedia.org/wiki/Lowest_common_ancestor} lca} between two
commits. *)vallca:[>read_write]t->info:Info.f->?max_depth:int->?n:int->commitlist->(commitoption,Merge.conflict)resultLwt.t(** Compute the lowest common ancestors ancestor of a list of commits by
recursively calling {!lcas} and merging the results.
If one of the merges results in a conflict, or if a call to {!lcas}
returns either [Error `Max_depth_reached] or [Error `Too_many_lcas] then
the function returns the same error. *)valthree_way_merge:[>read_write]t->info:Info.f->?max_depth:int->?n:int->commit->commit->(commit,Merge.conflict)resultLwt.t(** Compute the {!lcas} of the two commit and 3-way merge the result. *)valclosure:[>read]t->min:commitlist->max:commitlist->commitlistLwt.t(** Same as {{!NODE_GRAPH.closure} NODE_GRAPH.closure} but for the history
graph. *)valiter:[>read]t->min:nodelist->max:nodelist->?commit:(commit->unitLwt.t)->?edge:(node->node->unitLwt.t)->?skip:(node->boolLwt.t)->?rev:bool->unit->unitLwt.t(** Same as {{!NODE_GRAPH.iter} NODE_GRAPH.iter} but for traversing the
history graph. *)(** {1 Value Types} *)valcommit_t:commitType.t(** [commit_t] is the value type for {!commit}. *)endmoduletypeCommit=sigmoduletypeS=S(** [Make] provides a simple implementation of commit values, parameterized by
the commit and node keys [K]. *)moduleMake(K:Type.S):Swithtypehash=K.t(** V1 serialisation. *)moduleV1(C:S):sigincludeSwithtypehash=C.hashvalimport:C.t->tvalexport:t->C.tendmoduletypeSTORE=STORE(** [STORE] specifies the signature for commit stores. *)(** [Store] creates a new commit store. *)moduleStore(N:Node.STORE)(C:sigincludeCONTENT_ADDRESSABLE_STOREwithtypekey=N.keymoduleKey:Hash.Swithtypet=keymoduleVal:Swithtypet=valueandtypehash=keyend):STOREwithtype'at='aN.t*'aC.tandtypekey=C.keyandtypevalue=C.valueandtypeKey.t=C.Key.tandmoduleVal=C.ValmoduletypeHISTORY=HISTORY(** [History] specifies the signature for commit history. The history is
represented as a partial-order of commits and basic functions to search
through that history are provided.
Every commit can point to an entry point in a node graph, where
user-defined contents are stored. *)(** Build a commit history. *)moduleHistory(C:STORE):HISTORYwithtype'at='aC.tandtypev=C.Val.tandtypenode=C.Node.keyandtypecommit=C.keyend