Overlap whitelist broken with multiple projects
The overlap whitelist feature is not properly functional when used in conjunction with multiple projects, as the algorithm is based on simple element names and not element full paths.
This will break down in scenarios where multiple junctioned projects bear the same element names.
Consider the current approximate algorithm in Element.stage_dependency_artifacts()
, observe the XXX
comments I added in the fragment below:
for dep in self.dependencies(scope):
result = dep.stage_artifact(sandbox, path=path, include=include, exclude=exclude, orphans=orphans)
if result.overwritten:
for overwrite in result.overwritten:
# Completely new overwrite
if overwrite not in overlaps:
# Find the overwritten element by checking where we've
# written the element before
for elm, contents in files_written.items():
if overwrite in contents:
#
# XXX Here we take note of the Element's name, local to it's project
#
overlaps[overwrite] = [elm, dep.name]
else:
overlaps[overwrite].append(dep.name)
files_written[dep.name] = result.files_written
if result.ignored:
ignored[dep.name] = result.ignored
if overlaps:
overlap_warning = False
warning_detail = "Staged files overwrite existing files in staging area:\n"
for f, elements in overlaps.items():
overlap_warning_elements = []
# The bottom item overlaps nothing
overlapping_elements = elements[1:]
for elm in overlapping_elements:
#
# XXX Here we use `Element.search()` with a project-local element name,
# which may not be unique in the dependency graph.
#
element = cast(Element, self.search(scope, elm))
if not element.__file_is_whitelisted(f):
overlap_warning_elements.append(elm)
overlap_warning = True
warning_detail += _overlap_error_detail(f, overlap_warning_elements, elements)
if overlap_warning:
self.warn(
"Non-whitelisted overlaps detected", detail=warning_detail, warning_token=CoreWarnings.OVERLAPS
)
Edited by Tristan Van Berkom