##// END OF EJS Templates
import-checker: rotatecycle is actually the canonical cycle key...
Matt Mackall -
r24491:784b278b default
parent child Browse files
Show More
@@ -162,10 +162,6 b' def verify_stdlib_on_own_line(source):'
162 class CircularImport(Exception):
162 class CircularImport(Exception):
163 pass
163 pass
164
164
165
166 def cyclekey(names):
167 return tuple(sorted(names))
168
169 def checkmod(mod, imports):
165 def checkmod(mod, imports):
170 shortest = {}
166 shortest = {}
171 visit = [[mod]]
167 visit = [[mod]]
@@ -203,14 +199,14 b' def find_cycles(imports):'
203 top.bar -> top.baz -> top.foo -> top.bar
199 top.bar -> top.baz -> top.foo -> top.bar
204 top.foo -> top.qux -> top.foo
200 top.foo -> top.qux -> top.foo
205 """
201 """
206 cycles = {}
202 cycles = set()
207 for mod in sorted(imports.iterkeys()):
203 for mod in sorted(imports.iterkeys()):
208 try:
204 try:
209 checkmod(mod, imports)
205 checkmod(mod, imports)
210 except CircularImport, e:
206 except CircularImport, e:
211 cycle = e.args[0]
207 cycle = e.args[0]
212 cycles[cyclekey(cycle)] = ' -> '.join(rotatecycle(cycle))
208 cycles.add(" -> ".join(rotatecycle(cycle)))
213 return cycles.values()
209 return cycles
214
210
215 def _cycle_sortkey(c):
211 def _cycle_sortkey(c):
216 return len(c), c
212 return len(c), c
General Comments 0
You need to be logged in to leave comments. Login now