commandserver: cut import cycle by itself
authorYuya Nishihara <yuya@tcha.org>
Tue, 24 Nov 2015 23:03:54 +0900
changeset 27352 9fd8f1552369
parent 27351 28e50c4b15ed
child 27353 98e59d9e0d77
commandserver: cut import cycle by itself We generally make modules importable from the front-end layer, dispatch -> commands -> x. So the import cycle to dispatch should be resolved by the commandserver module.
mercurial/commands.py
mercurial/commandserver.py
--- a/mercurial/commands.py	Tue Nov 24 22:58:40 2015 +0900
+++ b/mercurial/commands.py	Tue Nov 24 23:03:54 2015 +0900
@@ -23,6 +23,7 @@
 import phases, obsolete, exchange, bundle2, repair, lock as lockmod
 import ui as uimod
 import streamclone
+import commandserver
 
 table = {}
 
@@ -6184,7 +6185,6 @@
         s.serve_forever()
 
     if opts["cmdserver"]:
-        import commandserver
         service = commandserver.createservice(ui, repo, opts)
     else:
         service = hgweb.createservice(ui, repo, opts)
--- a/mercurial/commandserver.py	Tue Nov 24 22:58:40 2015 +0900
+++ b/mercurial/commandserver.py	Tue Nov 24 23:03:54 2015 +0900
@@ -16,7 +16,6 @@
 
 from .i18n import _
 from . import (
-    dispatch,
     encoding,
     error,
     util,
@@ -186,6 +185,7 @@
     def runcommand(self):
         """ reads a list of \0 terminated arguments, executes
         and writes the return code to the result channel """
+        from . import dispatch  # avoid cycle
 
         length = struct.unpack('>I', self._read(4))[0]
         if not length: