changeset 24491:784b278b349c

import-checker: rotatecycle is actually the canonical cycle key So refactor to drop cyclekey().
author Matt Mackall <mpm@selenic.com>
date Sat, 28 Mar 2015 00:08:26 -0500
parents fb4639d5268e
children efa094701a05
files contrib/import-checker.py
diffstat 1 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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