Reconcile retained history accounting

This commit is contained in:
2026-10-26 17:46:31 +00:00
parent 12fd0a7191
commit 6a1447c327
8 changed files with 62 additions and 58 deletions

View File

@@ -85,6 +85,12 @@ func cloneInheritanceTransfer(transfer inheritanceTransfer) inheritanceTransfer
}
func cloneInheritanceOperations(operations []inheritanceOperation) []inheritanceOperation {
return copyInheritanceOperations(operations, true)
}
// copyInheritanceOperations detaches mutable operation metadata. History keeps
// the already immutable engine-owned document roots rather than copying them.
func copyInheritanceOperations(operations []inheritanceOperation, cloneDocuments bool) []inheritanceOperation {
if operations == nil {
return nil
}
@@ -101,8 +107,12 @@ func cloneInheritanceOperations(operations []inheritanceOperation) []inheritance
transfer := cloneInheritanceTransfer(*operation.transfer)
cloned[index].transfer = &transfer
}
cloned[index].parent = document.Clone(operation.parent)
cloned[index].effective = document.Clone(operation.effective)
cloned[index].parent = operation.parent
cloned[index].effective = operation.effective
if cloneDocuments {
cloned[index].parent = document.Clone(operation.parent)
cloned[index].effective = document.Clone(operation.effective)
}
cloned[index].childOrigins = cloneOriginIndex(operation.childOrigins)
cloned[index].parentOrigins = cloneOriginIndex(operation.parentOrigins)
cloned[index].effectiveOrigins = cloneOriginIndex(operation.effectiveOrigins)