# HG changeset patch # User Matt Mackall # Date 2015-03-28 05:08:26 # Node ID 784b278b349cf4fad70371aafa85fab5310a4930 # Parent fb4639d5268ed1f00c0878afa6dfa1b8eca21fa1 import-checker: rotatecycle is actually the canonical cycle key So refactor to drop cyclekey(). diff --git a/contrib/import-checker.py b/contrib/import-checker.py --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -162,10 +162,6 @@ def verify_stdlib_on_own_line(source): class CircularImport(Exception): pass - -def cyclekey(names): - return tuple(sorted(names)) - def checkmod(mod, imports): shortest = {} visit = [[mod]] @@ -203,14 +199,14 @@ def find_cycles(imports): top.bar -> top.baz -> top.foo -> top.bar top.foo -> top.qux -> top.foo """ - cycles = {} + cycles = set() for mod in sorted(imports.iterkeys()): try: checkmod(mod, imports) except CircularImport, e: cycle = e.args[0] - cycles[cyclekey(cycle)] = ' -> '.join(rotatecycle(cycle)) - return cycles.values() + cycles.add(" -> ".join(rotatecycle(cycle))) + return cycles def _cycle_sortkey(c): return len(c), c