import-checker: rotatecycle is actually the canonical cycle key
authorMatt Mackall <mpm@selenic.com>
Sat, 28 Mar 2015 00:08:26 -0500
changeset 24491 784b278b349c
parent 24490 fb4639d5268e
child 24492 efa094701a05
import-checker: rotatecycle is actually the canonical cycle key So refactor to drop cyclekey().
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