summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/config_diff.ml10
-rw-r--r--src/config_diff.mli1
-rw-r--r--src/internal.ml14
3 files changed, 12 insertions, 13 deletions
diff --git a/src/config_diff.ml b/src/config_diff.ml
index 87b2663..73c379b 100644
--- a/src/config_diff.ml
+++ b/src/config_diff.ml
@@ -456,3 +456,13 @@ let tree_union s t =
Vytree.make_full data (name_of v) (children_of v)
in
Tree_alg.ConfigAlg.tree_union s t f
+
+let tree_merge ?(destructive=false) s t =
+ let f u v =
+ let data =
+ match destructive with
+ | false -> data_of u
+ | true -> data_of v
+ in Vytree.make_full data (name_of v) (children_of v)
+ in
+ Tree_alg.ConfigAlg.tree_union s t f
diff --git a/src/config_diff.mli b/src/config_diff.mli
index 4262a58..fdc662c 100644
--- a/src/config_diff.mli
+++ b/src/config_diff.mli
@@ -45,6 +45,7 @@ val clone : ?recurse:bool -> ?set_values:string list option -> Config_tree.t ->
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 tree_merge : ?destructive:bool -> 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
val get_tagged_delete_tree : Config_tree.t -> Config_tree.t
diff --git a/src/internal.ml b/src/internal.ml
index a57f3db..5ee3926 100644
--- a/src/internal.ml
+++ b/src/internal.ml
@@ -21,17 +21,11 @@ module Make : FI = functor (M: T) -> struct
let yt = M.to_yojson x in
let ys = Yojson.Safe.to_string yt in
let fd = Unix.openfile file_name [Unix.O_CREAT;Unix.O_WRONLY] 0o664 in
- let () =
- try
- Unix.lockf fd Unix.F_TLOCK 0
- with _ ->
- Unix.close fd; raise (Write_error "write lock unavailable")
- in
let oc = Unix.out_channel_of_descr fd in
let () = Unix.ftruncate fd 0 in
let () = Printf.fprintf oc "%s" ys in
let () = Unix.fsync fd in
- let () = Unix.lockf fd Unix.F_ULOCK 0 in
+ let () = Unix.chmod file_name 0o664 in
close_out_noerr oc
let read_internal file_name =
@@ -43,12 +37,6 @@ module Make : FI = functor (M: T) -> struct
Printf.sprintf "%s %s: %s" (Unix.error_message e) f p
in raise (Read_error out)
in
- let () =
- try
- Unix.lockf fd Unix.F_TEST 0
- with _ ->
- Unix.close fd; raise (Read_error "read lock unavailable")
- in
let ic = Unix.in_channel_of_descr fd in
let ys = really_input_string ic (in_channel_length ic) in
let yt = Yojson.Safe.from_string ys in