Debian Codegraph @

stm/vcs.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (* This module builds a VCS like interface on top of Dag, used to build
12 a Dag instance by the State Transaction Machine.
13
14 This data structure does not hold system states:
15 - Edges are meant to hold a diff.
16 The delta between two states, or equivalent data like a vernac_expr whose
17 execution corresponds to the application of the diff.
18 - Nodes are empty, unless one adds explicit info.
19 The info could be a system state, obtaind by applying all the diffs
20 from the initial state, but is not necessarily there.
21 As a consequence, "checkout" just updates the current branch.
22
23 The type [id] is the type of commits (a node in the dag)
24 The type [Vcs.t] has 4 parameters:
25 ['info] data attached to a node (like a system state)
26 ['diff] data attached to an edge (the commit content, a "patch")
27 ['kind] extra data attached to a branch (like being the master branch)
28 ['cdata] extra data hold by dag properties
29 *)
30
31 module type Kind =
32 sig
33 type 'a t
34 val master : 'a t
35 end
36
37 module type S = sig
38
39 module Branch :
40 sig
41 type t
42 val make : string -> t
43 val equal : t -> t -> bool
44 val compare : t -> t -> int
45 val to_string : t -> string
46 val master : t
47 end
48
49 type id
50
51 type 'a kind_gen
52 type kind = Branch.t kind_gen
53
54 type branch_info = {
55 kind : kind;
56 root : id;
57 pos : id;
58 }
59
60 type ('diff,'info,'property_data) t
61
62 val empty : id -> ('diff,'info,'property_data) t
63
64 val current_branch : ('e,'i,'c) t -> Branch.t
65 val branches : ('e,'i,'c) t -> Branch.t list
66
67 val get_branch : ('e,'i,'c) t -> Branch.t -> branch_info
68 val reset_branch : ('e,'i,'c) t -> Branch.t -> id -> ('e,'i,'c) t
69 val branch :
70 ('e,'i,'c) t -> ?root:id -> ?pos:id ->
71 Branch.t -> kind -> ('e,'i,'c) t
72 val delete_branch : ('e,'i,'c) t -> Branch.t -> ('e,'i,'c) t
73 val merge :
74 ('diff,'i,'c) t -> id -> ours:'diff -> theirs:'diff -> ?into:Branch.t ->
75 Branch.t -> ('diff,'i,'c) t
76 val commit : ('diff,'i,'c) t -> id -> 'diff -> ('diff,'i,'c) t
77 val rewrite_merge :
78 ('diff,'i,'c) t -> id -> ours:'diff -> theirs:'diff -> at:id ->
79 Branch.t -> ('diff,'i,'c) t
80 val checkout : ('e,'i,'c) t -> Branch.t -> ('e,'i,'c) t
81
82 val set_info : ('e,'info,'c) t -> id -> 'info -> ('e,'info,'c) t
83 val get_info : ('e,'info,'c) t -> id -> 'info option
84
85 (* Read only dag *)
86 module Dag : Dag.S with type node = id
87 val dag : ('diff,'info,'cdata) t -> ('diff,'info,'cdata) Dag.t
88
89 (* Properties are not a concept typical of a VCS, but a useful metadata
90 * of a DAG (or graph). *)
91 val create_property : ('e,'i,'c) t -> id list -> 'c -> ('e,'i,'c) t
92 val property_of : ('e,'i,'c) t -> id -> 'c Dag.Property.t list
93 val delete_property : ('e,'i,'c) t -> 'c Dag.Property.t -> ('e,'i,'c) t
94
95 (* Removes all unreachable nodes and returns them *)
96 val gc : ('e,'info,'c) t -> ('e,'info,'c) t * Dag.NodeSet.t
97 val reachable : ('e,'info,'c) t -> id -> Dag.NodeSet.t
98
99
100 end
101
102 module Make(OT : Map.OrderedType)(K : Kind) : S
103 with type id = OT.t
104 and type Dag.node = OT.t
105 and type 'a kind_gen = 'a K.t
106 and type Dag.NodeSet.t = Set.Make(OT).t
107 and type Dag.NodeSet.elt = OT.t
108