Persistent store with Git semantics: lazy reads, delayed writes, content-addressing
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

irmin: merge returns cursor, not hash

+35 -13
+8 -1
lib/schema.ml
··· 452 452 in 453 453 merge_names [] all_names 454 454 in 455 - merge_hash schema ancestor ours theirs 455 + let get_hash c = 456 + match c.source with `Block h -> h | `Inline d -> H.hash_block d 457 + in 458 + match 459 + merge_hash schema (get_hash ancestor) (get_hash ours) (get_hash theirs) 460 + with 461 + | Error _ as e -> e 462 + | Ok merged_hash -> Ok (at heap schema merged_hash) 456 463 457 464 (* ===== Proof ===== *) 458 465
+5 -5
lib/schema.mli
··· 172 172 val merge : 173 173 (H.hash, H.block, _) Heap.t -> 174 174 t -> 175 - ancestor:H.hash -> 176 - ours:H.hash -> 177 - theirs:H.hash -> 178 - (H.hash, [ `Conflict of string ]) result 175 + ancestor:cursor -> 176 + ours:cursor -> 177 + theirs:cursor -> 178 + (cursor, [ `Conflict of string ]) result 179 179 (** [merge heap schema ~ancestor ~ours ~theirs] performs a 3-way merge. 180 - Returns the hash of the merged tree, or a conflict. *) 180 + Returns a cursor at the merged tree, or a conflict. *) 181 181 182 182 (** {1:proof Proofs} 183 183
+22 -7
test/tar/test.ml
··· 219 219 Irmin_tar.of_entries heap 220 220 [ ("a.txt", "hello"); ("b.txt", "world"); ("d.txt", "new-theirs") ] 221 221 in 222 - match S.merge heap Irmin_tar.tree ~ancestor ~ours ~theirs with 222 + match 223 + S.merge heap Irmin_tar.tree 224 + ~ancestor:(S.at heap Irmin_tar.tree ancestor) 225 + ~ours:(S.at heap Irmin_tar.tree ours) 226 + ~theirs:(S.at heap Irmin_tar.tree theirs) 227 + with 223 228 | Error (`Conflict msg) -> Alcotest.failf "merge conflict: %s" msg 224 - | Ok merged_root -> 225 - let c = S.at heap Irmin_tar.tree merged_root in 229 + | Ok merged -> 230 + let c = merged in 226 231 let kids = S.list c |> List.map fst |> List.sort String.compare in 227 232 Alcotest.(check (list string)) 228 233 "merged" ··· 240 245 let ancestor = Irmin_tar.of_entries heap [ ("views.counter", "10") ] in 241 246 let ours = Irmin_tar.of_entries heap [ ("views.counter", "15") ] in 242 247 let theirs = Irmin_tar.of_entries heap [ ("views.counter", "12") ] in 243 - match S.merge heap tree_with_counters ~ancestor ~ours ~theirs with 248 + match 249 + S.merge heap tree_with_counters 250 + ~ancestor:(S.at heap tree_with_counters ancestor) 251 + ~ours:(S.at heap tree_with_counters ours) 252 + ~theirs:(S.at heap tree_with_counters theirs) 253 + with 244 254 | Error (`Conflict msg) -> Alcotest.failf "merge conflict: %s" msg 245 - | Ok merged_root -> 246 - let c = S.at heap tree_with_counters merged_root in 255 + | Ok merged -> 256 + let c = merged in 247 257 (* 15 + 12 - 10 = 17 *) 248 258 Alcotest.(check (option string)) 249 259 "counter merged" (Some "17") ··· 256 266 let ours = Irmin_tar.of_entries heap [ ("a.txt", "ours-edit") ] in 257 267 let theirs = Irmin_tar.of_entries heap [ ("a.txt", "theirs-edit") ] in 258 268 (* No merge function for opaque blobs → conflict *) 259 - match S.merge heap Irmin_tar.tree ~ancestor ~ours ~theirs with 269 + match 270 + S.merge heap Irmin_tar.tree 271 + ~ancestor:(S.at heap Irmin_tar.tree ancestor) 272 + ~ours:(S.at heap Irmin_tar.tree ours) 273 + ~theirs:(S.at heap Irmin_tar.tree theirs) 274 + with 260 275 | Ok _ -> Alcotest.fail "should conflict" 261 276 | Error (`Conflict _) -> () 262 277