changeset 24487:642d245ff537

import-checker: fix rotatecycle It was duplicating the last element sometimes.
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Mar 2015 18:50:39 -0500
parents 1a9efc312700
children 4b3fc46097f7
files contrib/import-checker.py tests/test-module-imports.t
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/import-checker.py	Fri Mar 27 01:03:06 2015 -0700
+++ b/contrib/import-checker.py	Fri Mar 27 18:50:39 2015 -0500
@@ -191,7 +191,7 @@
     """
     lowest = min(cycle)
     idx = cycle.index(lowest)
-    return cycle[idx:] + cycle[1:idx] + [lowest]
+    return cycle[idx:-1] + cycle[:idx] + [lowest]
 
 def find_cycles(imports):
     """Find cycles in an already-loaded import graph.
@@ -201,8 +201,8 @@
     ...            'top.baz': ['foo'],
     ...            'top.qux': ['foo']}
     >>> print '\\n'.join(sorted(find_cycles(imports)))
-    top.bar -> top.baz -> top.foo -> top.bar -> top.bar
-    top.foo -> top.qux -> top.foo -> top.foo
+    top.bar -> top.baz -> top.foo -> top.bar
+    top.foo -> top.qux -> top.foo
     """
     cycles = {}
     for mod in sorted(imports.iterkeys()):
--- a/tests/test-module-imports.t	Fri Mar 27 01:03:06 2015 -0700
+++ b/tests/test-module-imports.t	Fri Mar 27 18:50:39 2015 -0500
@@ -39,4 +39,4 @@
   mercurial/ui.py mixed imports
      stdlib:    formatter
      relative:  config, error, scmutil, util
-  Import cycle: mercurial.cmdutil -> mercurial.context -> mercurial.subrepo -> mercurial.cmdutil -> mercurial.cmdutil
+  Import cycle: mercurial.cmdutil -> mercurial.context -> mercurial.subrepo -> mercurial.cmdutil