···452452 in
453453 merge_names [] all_names
454454 in
455455- merge_hash schema ancestor ours theirs
455455+ let get_hash c =
456456+ match c.source with `Block h -> h | `Inline d -> H.hash_block d
457457+ in
458458+ match
459459+ merge_hash schema (get_hash ancestor) (get_hash ours) (get_hash theirs)
460460+ with
461461+ | Error _ as e -> e
462462+ | Ok merged_hash -> Ok (at heap schema merged_hash)
456463457464 (* ===== Proof ===== *)
458465
+5-5
lib/schema.mli
···172172 val merge :
173173 (H.hash, H.block, _) Heap.t ->
174174 t ->
175175- ancestor:H.hash ->
176176- ours:H.hash ->
177177- theirs:H.hash ->
178178- (H.hash, [ `Conflict of string ]) result
175175+ ancestor:cursor ->
176176+ ours:cursor ->
177177+ theirs:cursor ->
178178+ (cursor, [ `Conflict of string ]) result
179179 (** [merge heap schema ~ancestor ~ours ~theirs] performs a 3-way merge.
180180- Returns the hash of the merged tree, or a conflict. *)
180180+ Returns a cursor at the merged tree, or a conflict. *)
181181182182 (** {1:proof Proofs}
183183
+22-7
test/tar/test.ml
···219219 Irmin_tar.of_entries heap
220220 [ ("a.txt", "hello"); ("b.txt", "world"); ("d.txt", "new-theirs") ]
221221 in
222222- match S.merge heap Irmin_tar.tree ~ancestor ~ours ~theirs with
222222+ match
223223+ S.merge heap Irmin_tar.tree
224224+ ~ancestor:(S.at heap Irmin_tar.tree ancestor)
225225+ ~ours:(S.at heap Irmin_tar.tree ours)
226226+ ~theirs:(S.at heap Irmin_tar.tree theirs)
227227+ with
223228 | Error (`Conflict msg) -> Alcotest.failf "merge conflict: %s" msg
224224- | Ok merged_root ->
225225- let c = S.at heap Irmin_tar.tree merged_root in
229229+ | Ok merged ->
230230+ let c = merged in
226231 let kids = S.list c |> List.map fst |> List.sort String.compare in
227232 Alcotest.(check (list string))
228233 "merged"
···240245 let ancestor = Irmin_tar.of_entries heap [ ("views.counter", "10") ] in
241246 let ours = Irmin_tar.of_entries heap [ ("views.counter", "15") ] in
242247 let theirs = Irmin_tar.of_entries heap [ ("views.counter", "12") ] in
243243- match S.merge heap tree_with_counters ~ancestor ~ours ~theirs with
248248+ match
249249+ S.merge heap tree_with_counters
250250+ ~ancestor:(S.at heap tree_with_counters ancestor)
251251+ ~ours:(S.at heap tree_with_counters ours)
252252+ ~theirs:(S.at heap tree_with_counters theirs)
253253+ with
244254 | Error (`Conflict msg) -> Alcotest.failf "merge conflict: %s" msg
245245- | Ok merged_root ->
246246- let c = S.at heap tree_with_counters merged_root in
255255+ | Ok merged ->
256256+ let c = merged in
247257 (* 15 + 12 - 10 = 17 *)
248258 Alcotest.(check (option string))
249259 "counter merged" (Some "17")
···256266 let ours = Irmin_tar.of_entries heap [ ("a.txt", "ours-edit") ] in
257267 let theirs = Irmin_tar.of_entries heap [ ("a.txt", "theirs-edit") ] in
258268 (* No merge function for opaque blobs → conflict *)
259259- match S.merge heap Irmin_tar.tree ~ancestor ~ours ~theirs with
269269+ match
270270+ S.merge heap Irmin_tar.tree
271271+ ~ancestor:(S.at heap Irmin_tar.tree ancestor)
272272+ ~ours:(S.at heap Irmin_tar.tree ours)
273273+ ~theirs:(S.at heap Irmin_tar.tree theirs)
274274+ with
260275 | Ok _ -> Alcotest.fail "should conflict"
261276 | Error (`Conflict _) -> ()
262277