diff options
Diffstat (limited to 'src/config_diff.ml')
-rw-r--r-- | src/config_diff.ml | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/config_diff.ml b/src/config_diff.ml index 35a5b55..3529a5d 100644 --- a/src/config_diff.ml +++ b/src/config_diff.ml @@ -390,6 +390,35 @@ let show_diff ?(cmds=false) path left right = in strs +let is_terminal_path node path = + try + let n = Vytree.get node path in + match (Vytree.children_of_node n) with + | [] -> true + | _ -> false + with Vytree.Nonexistent_path -> false + +(* mask function; mask applied on right *) +let mask_func ?recurse:_ (path : string list) (Diff_tree res) (m : change) = + match m with + | Added -> Diff_tree (res) + | Subtracted -> + (match path with + | [_] -> Diff_tree {res with left = Vytree.delete res.left path} + | _ -> if not (is_terminal_path res.right (list_but_last path)) then + Diff_tree {res with left = Vytree.delete res.left path} + else Diff_tree (res)) + | Unchanged -> Diff_tree (res) + | Updated _ -> Diff_tree (res) + +(* call recursive diff with mask_func; mask applied on right *) +let mask_tree left right = + let trees = make_diff_trees left right in + let d = diff [] mask_func trees (Option.some left, Option.some right) + in + let res = eval_result d in + res.left + let union_of_values (n : Config_tree.t) (m : Config_tree.t) = let set_n = ValueS.of_list (data_of n).values in let set_m = ValueS.of_list (data_of m).values in |