# HG changeset patch # User Matt Mackall # Date 1427519306 18000 # Node ID 784b278b349cf4fad70371aafa85fab5310a4930 # Parent fb4639d5268ed1f00c0878afa6dfa1b8eca21fa1 import-checker: rotatecycle is actually the canonical cycle key So refactor to drop cyclekey(). diff -r fb4639d5268e -r 784b278b349c contrib/import-checker.py --- a/contrib/import-checker.py Fri Mar 27 23:52:23 2015 -0500 +++ b/contrib/import-checker.py Sat Mar 28 00:08:26 2015 -0500 @@ -162,10 +162,6 @@ class CircularImport(Exception): pass - -def cyclekey(names): - return tuple(sorted(names)) - def checkmod(mod, imports): shortest = {} visit = [[mod]] @@ -203,14 +199,14 @@ 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