diff options
Diffstat (limited to 'src/config_diff.ml')
| -rw-r--r-- | src/config_diff.ml | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/config_diff.ml b/src/config_diff.ml index 6fd57c6..09167b3 100644 --- a/src/config_diff.ml +++ b/src/config_diff.ml @@ -432,29 +432,10 @@ let union_of_values (n : Config_tree.t) (m : Config_tree.t) = let set_m = ValueS.of_list (data_of m).values in ValueS.elements (ValueS.union set_n set_m) -let union_of_children n m = - let set_n = ChildrenS.of_list (children_of n) in - let set_m = ChildrenS.of_list (children_of m) in - ChildrenS.elements (ChildrenS.union set_n set_m) - -(* tree_union is currently used only for unit tests, so only values of data - are considered. Should there be a reason to expose it in the future, - consistency check and union of remaining data will need to be added. - *) -let rec tree_union s t = - let child_of_union s t c = - let s_c = Vytree.find s (name_of c) in - let t_c = Vytree.find t (name_of c) in - match s_c, t_c with - | Some child, None -> clone s t [(name_of child)] - | None, Some _ -> t - | Some u, Some v -> - if u ^~ v then - let values = union_of_values u v in - let data = {(data_of v) with Config_tree.values = values} in - Vytree.replace t (Vytree.make data (name_of v)) - else - Vytree.replace t (tree_union u v) - | None, None -> raise Nonexistent_child +let tree_union s t = + let f u v = + let values = union_of_values u v in + let data = {(data_of v) with Config_tree.values = values} in + Vytree.make_full data (name_of v) (children_of v) in - List.fold_left (fun x c -> child_of_union s x c) t (union_of_children s t) + Tree_alg.ConfigAlg.tree_union s t f |
