diff options
| author | John Estabrook <jestabro@vyos.io> | 2024-12-24 08:42:44 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-01-15 19:08:27 -0600 |
| commit | 2948c7fa86dc3e7eba4f731f5dce8fbb03de6ad2 (patch) | |
| tree | af184a6387e41a2ce42fd35be50935635cc13f6d /src/config_diff.ml | |
| parent | 57b164b82c2c39cba2fd910c22226bb5b59a71b4 (diff) | |
| download | vyos1x-config-2948c7fa86dc3e7eba4f731f5dce8fbb03de6ad2.tar.gz vyos1x-config-2948c7fa86dc3e7eba4f731f5dce8fbb03de6ad2.zip | |
T7046: use generalized tree_union for config_diff nosetest
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 |
