Recursively searching for non-empty ancestors of enhanced dependencies with empty parents #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current solution of deleting enhanced dependencies (
deps
field) to empty parents fails in validation tests with a few error of the following type:The reason is that it just deletes the dependencies to empty parents and replaces them with a dependency to "0:root" only if no other has left. However, exceptionally it happens that a dependency to an empty parent is the only connection of a set of nodes to the rest of the tree, making them unreachable from the root after deleting the empty parent.
The suggested solution first checks if the root remains reachable after deletion of all empty nodes. If yes, it just removes the empty-parent dependencies. Otherwise, it tries to replace the dependency to an empty parent with the empty parent's dependencies. If these deps also contain an empty-parent dependency, replacing is recursively repeated to the ancestors until all dependencies point to non-empty parents. If no non-empty parents can be found during this procedure (a cycle is encountered), the problematic dependency is replaced with
0:root
.