Fix underlay provenance and resource path handling
This commit is contained in:
@@ -125,9 +125,6 @@ func applyOverlayMetadata(metadata *Metadata, records []overlayRecord) {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if history := events[pointer]; len(history) != 0 && history[len(history)-1].Origin.Layer == info.Origin.Layer && history[len(history)-1].Origin.Operation == info.Origin.Operation {
|
||||
continue
|
||||
}
|
||||
appendInputOriginEvent(events, baseline, pointer, path, info.Origin)
|
||||
}
|
||||
metadata.history = make(map[string][]Change, len(baseline)+len(events))
|
||||
@@ -144,12 +141,37 @@ func appendInputOriginEvent(events map[string][]Change, baseline map[string][]Ch
|
||||
return
|
||||
}
|
||||
history := events[pointer]
|
||||
if len(history) != 0 && originContainedBy(history[len(history)-1].Origin, origin) {
|
||||
if len(history) != 0 && originRepresentedByChange(path, origin, history[len(history)-1]) {
|
||||
return
|
||||
}
|
||||
appendInputChangeEvent(events, baseline, pointer, Change{Path: path.clone(), Origin: cloneOrigin(origin)})
|
||||
}
|
||||
|
||||
func originRepresentedByChange(path Path, origin Origin, change Change) bool {
|
||||
if change.Path.String() == path.String() {
|
||||
return originContainedBy(origin, change.Origin)
|
||||
}
|
||||
if !pathContains(change.Path, path) || origin.Layer != change.Origin.Layer || origin.Operation != change.Origin.Operation {
|
||||
return false
|
||||
}
|
||||
// A subtree replacement already records its descendants' contributions.
|
||||
// Their coordinates differ from the container's, but their sources must be
|
||||
// covered by the operation; matching only the precedence role is insufficient.
|
||||
for _, location := range origin.Locations {
|
||||
found := false
|
||||
for _, recorded := range change.Origin.Locations {
|
||||
if location.SourceID == recorded.SourceID {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func appendInputChangeEvent(events map[string][]Change, baseline map[string][]Change, pointer string, value Change) {
|
||||
change := cloneChange(value)
|
||||
history := events[pointer]
|
||||
|
||||
Reference in New Issue
Block a user