Normalize inheritance history evidence
This commit is contained in:
@@ -104,54 +104,7 @@ func historyWithInheritance(path Path, stored []Change, operations []inheritance
|
||||
}
|
||||
|
||||
func projectedInheritanceChanges(query Path, operation inheritanceOperation) []Change {
|
||||
if operation.control != nil {
|
||||
if !pathsIntersect(operation.control.path, query) {
|
||||
return nil
|
||||
}
|
||||
origin := cloneOrigin(operation.controlOrigin)
|
||||
origin.Operation = ChangeInheritance
|
||||
origin.Inheritance = projectInheritanceSteps(origin)
|
||||
return []Change{{Path: operation.control.path.clone(), Origin: origin,
|
||||
Dependencies: []Path{operation.control.path.clone()}}}
|
||||
}
|
||||
if operation.transfer == nil || !pathsIntersect(operation.transfer.to, query) || inheritanceOperationIdentity(operation, query) {
|
||||
return nil
|
||||
}
|
||||
path := query
|
||||
if pathContains(query, operation.transfer.to) {
|
||||
path = operation.transfer.to
|
||||
}
|
||||
var changes []Change
|
||||
parent, parentFound := transferredOperationOrigin(operation, path)
|
||||
if parentFound {
|
||||
parent.Operation = ChangeInheritance
|
||||
parent.Inheritance = projectInheritanceSteps(parent)
|
||||
changes = append(changes, Change{
|
||||
Path: path.clone(), Origin: parent,
|
||||
Dependencies: []Path{operation.transfer.from.clone(), operation.transfer.reference.clone()},
|
||||
})
|
||||
}
|
||||
effective, effectiveFound := operation.effectiveOrigins[path.String()]
|
||||
if effectiveFound {
|
||||
effective = cloneOrigin(effective)
|
||||
effective.Operation = ChangeInheritance
|
||||
}
|
||||
if effectiveFound && (!parentFound || !originContainedBy(effective, parent)) {
|
||||
effective.Inheritance = projectInheritanceSteps(effective)
|
||||
changes = append(changes, Change{
|
||||
Path: path.clone(), Origin: effective,
|
||||
Dependencies: []Path{operation.transfer.reference.clone()},
|
||||
})
|
||||
} else if parentFound && !effectiveFound {
|
||||
removed := cloneOrigin(operation.effectiveOrigins[operation.transfer.to.String()])
|
||||
removed.Operation = ChangeInheritance
|
||||
removed.Inheritance = projectInheritanceSteps(removed)
|
||||
changes = append(changes, Change{
|
||||
Path: operation.transfer.to.clone(), Origin: removed,
|
||||
Dependencies: []Path{operation.transfer.reference.clone()},
|
||||
})
|
||||
}
|
||||
return changes
|
||||
return inheritanceChangesForQuery(query, operation)
|
||||
}
|
||||
|
||||
func transferredOperationOrigin(operation inheritanceOperation, destination Path) (Origin, bool) {
|
||||
|
||||
Reference in New Issue
Block a user