diff options
-rw-r--r-- | src/config_diff.ml | 26 | ||||
-rw-r--r-- | src/config_diff.mli | 10 |
2 files changed, 26 insertions, 10 deletions
diff --git a/src/config_diff.ml b/src/config_diff.ml index 3529a5d..6fd57c6 100644 --- a/src/config_diff.ml +++ b/src/config_diff.ml @@ -27,6 +27,7 @@ module Diff_cstore = struct type t = { left: Config_tree.t; right: Config_tree.t; handle: int; + out: string; } end @@ -43,19 +44,23 @@ let eval_result : type a. a result -> a = function type 'a diff_func = ?recurse:bool -> string list -> 'a result -> change -> 'a result let make_diff_trees l r = Diff_tree { left = l; right = r; - add = (Config_tree.make ""); - sub = (Config_tree.make ""); - del = (Config_tree.make ""); - inter = (Config_tree.make ""); + add = (Config_tree.make ""); + sub = (Config_tree.make ""); + del = (Config_tree.make ""); + inter = (Config_tree.make ""); } -let make_diff_string l r = Diff_string { - left = l; right = r; - skel = (Config_tree.make ""); - ppath = []; - udiff = ""; +let make_diff_string l r = Diff_string { left = l; right = r; + skel = (Config_tree.make ""); + ppath = []; + udiff = ""; } +let make_diff_cstore l r h = Diff_cstore { left = l; right = r; + handle = h; + out = ""; +} + let name_of n = Vytree.name_of_node n let data_of n = Vytree.data_of_node n let children_of n = Vytree.children_of_node n @@ -75,6 +80,9 @@ module TreeOrd = struct end module ChildrenS = Set.Make(TreeOrd) +(* unordered set of values *) +module ValueSet = Set.Make(String) + let (^~) (node : Config_tree.t) (node' : Config_tree.t) = name_of node = name_of node' && (data_of node).values <> (data_of node').values diff --git a/src/config_diff.mli b/src/config_diff.mli index 6adf5a7..af8f87d 100644 --- a/src/config_diff.mli +++ b/src/config_diff.mli @@ -1,3 +1,4 @@ +type change = Unchanged | Added | Subtracted | Updated of string list module Diff_tree : sig type t = { left: Config_tree.t; @@ -11,7 +12,7 @@ end module Diff_string : sig type t = { left: Config_tree.t; - right : Config_tree.t; + right: Config_tree.t; skel: Config_tree.t; ppath: string list; udiff: string; @@ -22,6 +23,7 @@ module Diff_cstore : sig type t = { left: Config_tree.t; right: Config_tree.t; handle: int; + out: string; } end @@ -30,6 +32,11 @@ type _ result = | Diff_string : Diff_string.t -> Diff_string.t result | Diff_cstore : Diff_cstore.t -> Diff_cstore.t result +val eval_result : 'a result -> 'a + +type 'a diff_func = ?recurse:bool -> string list -> 'a result -> change -> 'a result +val diff : string list -> 'a diff_func -> 'a result -> Config_tree.t option * Config_tree.t option -> 'a result + exception Incommensurable exception Empty_comparison exception Nonexistent_child @@ -38,3 +45,4 @@ val diff_tree : string list -> Config_tree.t -> Config_tree.t -> Config_tree.t val show_diff : ?cmds:bool -> string list -> Config_tree.t -> Config_tree.t -> string val tree_union : Config_tree.t -> Config_tree.t -> Config_tree.t val mask_tree : Config_tree.t -> Config_tree.t -> Config_tree.t +val make_diff_cstore : Config_tree.t -> Config_tree.t -> int -> Diff_cstore.t result |