if self._reverse:
tsorted = reversed(tsorted)
roots = set(root.address.spec for root in self.context.target_roots)
for address in tsorted:
if address in roots:
yield address
After Change
def console_output(self, targets):
sorted_targets = sort_targets(targets)
// sort_targets already returns targets in reverse topologically sorted order.
if not self.get_options().reverse:
sorted_targets = reversed(sorted_targets)
for target in sorted_targets:
if target in self.context.target_roots: