repos.recursive_buid_report: Try breaking cycles
Instead of falling back to alphabetical order when cycle is detected, we try to break it and form the topological order again. Even if cycles are broken at the wrong edge, this order might still be more useful. All the cycles found are included into the report.
This commit is contained in:
parent
09f9a563f0
commit
02b3453509
@ -393,11 +393,18 @@ def recursive_build_report(from_repo, to_repo, *source_names,
|
||||
dep_sources.add(b.source_name)
|
||||
full_req[source] = dep_sources
|
||||
|
||||
cycles = []
|
||||
while True:
|
||||
try:
|
||||
order = list(graphlib.TopologicalSorter(full_req).static_order())
|
||||
except graphlib.CycleError as ex:
|
||||
LOG.error("Cycle detected: %s", ex)
|
||||
order = sorted(build_source_deps)
|
||||
LOG.warning("Cycle detected: %s", ex)
|
||||
cycle = ex.args[1]
|
||||
cycles.append(cycle)
|
||||
# break the cycle and retry
|
||||
full_req[cycle[1]].remove(cycle[0])
|
||||
else:
|
||||
break
|
||||
|
||||
reports.append('\n== SUMMARY ==\n')
|
||||
for source in order:
|
||||
@ -412,6 +419,11 @@ def recursive_build_report(from_repo, to_repo, *source_names,
|
||||
reports.extend('\t%s' % source.decode()
|
||||
for source in sorted(self_dependent))
|
||||
|
||||
if cycles:
|
||||
reports.append('\nCycles:')
|
||||
reports.extend('\t%s' % ' '.join(source.decode() for source in c)
|
||||
for c in cycles)
|
||||
|
||||
special = set()
|
||||
for source_name in order:
|
||||
source = to_repo.sources.get(source_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user