diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-05-12 15:16:23 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-05-12 15:16:23 -0700 |
commit | 75ff9dea4e2bc141e53acaf7edb43f8b54fc56e5 (patch) | |
tree | c959ec546168d3744b7c5716fbae304a91a06065 /pym/portage/util | |
parent | test_digraph: fix bfs for PYTHONHASHSEED=random (diff) | |
download | portage-75ff9dea4e2bc141e53acaf7edb43f8b54fc56e5.tar.gz portage-75ff9dea4e2bc141e53acaf7edb43f8b54fc56e5.tar.bz2 portage-75ff9dea4e2bc141e53acaf7edb43f8b54fc56e5.zip |
test_digraph: fix get_cycles for PYTHONHASHSEED
Diffstat (limited to 'pym/portage/util')
-rw-r--r-- | pym/portage/util/digraph.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/pym/portage/util/digraph.py b/pym/portage/util/digraph.py index 1bbe10f61..f3ae658c9 100644 --- a/pym/portage/util/digraph.py +++ b/pym/portage/util/digraph.py @@ -317,16 +317,23 @@ class digraph(object): """ all_cycles = [] for node in self.nodes: + # If we have multiple paths of the same length, we have to + # return them all, so that we always get the same results + # even with PYTHONHASHSEED="random" enabled. shortest_path = None + candidates = [] for child in self.child_nodes(node, ignore_priority): path = self.shortest_path(child, node, ignore_priority) if path is None: continue - if not shortest_path or len(shortest_path) > len(path): + if not shortest_path or len(shortest_path) >= len(path): shortest_path = path - if shortest_path: - if not max_length or len(shortest_path) <= max_length: - all_cycles.append(shortest_path) + candidates.append(path) + if shortest_path and \ + (not max_length or len(shortest_path) <= max_length): + for path in candidates: + if len(path) == len(shortest_path): + all_cycles.append(path) return all_cycles # Backward compatibility |