]> dreyeck.freedombox.rocks Git - topic-maps.git/blobdiff - src/tmdm/merging.lisp
test(ctm): register seven reviewed negative Slice 20B contracts
[topic-maps.git] / src / tmdm / merging.lisp
index 0fcb878e558d4283e8c07f3b9cfd0c09b4d35073..b34766d0fdaaca222277e7b5c1195370648bf149 100644 (file)
   (check-variant-merge-constraints map)
   (loop for before = (length (map-information-items map)) do
     (loop for pair = (equal-pair (%topic-map-topics map) #'equal-topics-p)
-          while pair do (merge-two-topics map (first pair) (second pair)))
+          while pair do
+      ;; A staged import may contain equal owners/types AND equal Reifier
+      ;; Topics whose Names/Occurrences/etc. have not merged yet. First perform
+      ;; available nonconflicting Topic merges; their ordinary item merging can
+      ;; resolve those Reified references. Do not let collection order invent a
+      ;; conflict. If none can proceed, MERGE-TWO-TOPICS still signals TMDM 6.2's
+      ;; conflict; no equality or conflict rule is relaxed.
+      (let ((ready (equal-pair (%topic-map-topics map)
+                     (lambda (a b)
+                       (and (equal-topics-p a b)
+                            (let ((left (topic-reified a)) (right (topic-reified b)))
+                              (not (and left right (not (eq left right))))))))))
+        (let ((next (or ready pair)))
+          (merge-two-topics map (first next) (second next)))))
     (normalize-names map) (normalize-occurrences map) (normalize-associations map)
     when (= before (length (map-information-items map))) return map))