The old method of detecting recursive dependencies was overcomplicated
and only worked in the simple case of A → B → C → A and not
A → B → C → B. This new method works as follows:
- Given a dependency path…
- Get all of the links in the last document in the path.
- If there are no links, return the path.
- If there are links which point to a file in the path, it is a
recursive dependency. Return the path ending at the point of
recursion.
- Otherwise (there are nonrecursive links), process each path which
results from appending each link to the end of the current path and
return all of them.
The algorithm ends with a set of paths to leaf nodes in the dependency
tree, and each nonroot node in this tree (leaf or branch) is a
dependency. This is what the behaviour should have been from the
beginning. (The old method attempted to process the tree in layers,
rather than as a set of paths.)