Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
at inode 75 lines 2.3 kB view raw
1(** Subtree operations for monorepo management. 2 3 This module provides first-class subtree operations that replace the need to 4 shell out to [git subtree] commands. *) 5 6(** {1 Subtree Functor} *) 7 8module Make (F : Codec.S) : sig 9 type hash = F.hash 10 11 module Store : module type of Store.Make (F) 12 13 (** {2 Subtree Split} *) 14 15 val split : Store.t -> prefix:Store.Tree.path -> Store.t 16 (** [split store ~prefix] extracts the subtree at [prefix] into a new store 17 with rewritten history containing only commits that touch that prefix. 18 19 Like [git subtree split --prefix]. *) 20 21 (** {2 Subtree Add} *) 22 23 val add : Store.t -> prefix:Store.Tree.path -> source:Store.t -> hash 24 (** [add store ~prefix ~source] adds the contents of [source] as a subtree at 25 [prefix], creating a merge commit. 26 27 Like [git subtree add --prefix --squash]. *) 28 29 (** {2 Subtree Pull} *) 30 31 val pull : 32 Store.t -> 33 prefix:Store.Tree.path -> 34 source:Store.t -> 35 (hash, [> `Conflict of Store.Tree.path list ]) result 36 (** [pull store ~prefix ~source] pulls updates from [source] into the subtree 37 at [prefix]. 38 39 Like [git subtree pull --prefix --squash]. *) 40 41 (** {2 Subtree Push} *) 42 43 val push : Store.t -> prefix:Store.Tree.path -> target:Store.t -> hash 44 (** [push store ~prefix ~target] pushes changes from the subtree at [prefix] 45 to [target]. 46 47 Like [git subtree push --prefix]. *) 48 49 (** {2 Status} *) 50 51 type status = 52 [ `In_sync 53 | `Local_ahead of int 54 | `Remote_ahead of int 55 | `Diverged of int * int (** local, remote *) 56 | `Trees_differ ] 57 58 val status : Store.t -> prefix:Store.Tree.path -> external_:Store.t -> status 59 (** [status store ~prefix ~external_] compares the subtree at [prefix] with 60 the external store. 61 62 - [`In_sync]: Trees are identical 63 - [`Local_ahead n]: Local has n commits not in external 64 - [`Remote_ahead n]: External has n commits not in local 65 - [`Diverged]: Both have independent commits 66 - [`Trees_differ]: Trees differ but no history relationship *) 67end 68 69(** {1 Pre-instantiated Subtree} *) 70 71module Git : module type of Make (Codec.Git) 72(** Git-format subtree operations. *) 73 74module Mst : module type of Make (Codec.Mst) 75(** MST-format subtree operations. *)