Skip to content

add_origin: rework the code to use a proper queue

When the root node had no origin, the previous code was adding the full tree to the queue (through the node.iter_tree in the else close). leading to issuing a request for every single node in the tree.

The new code only adds the direct children to the queue as we know that we don't have any other way¹ to get information about them. In addition we now use a deque for efficiency.

Mypy required more wrestling that expect because the swh.model is not helping us too much here. This would be an interesting cleanup to do, but out of scope of this series.

[1] except for the rare case where they would exist as duplicate in another part of the graph. The seen set is here to handle these possibilities.

Merge request reports