changeset 30512:cc374292a561

chgserver: delay importing commands and dispatch modules This is a workaround for future import cycle: dispatch -> commands -> server -> chgserver -> commands. Some of the problems can be fixed later on pager and chg refactoring.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 15 Oct 2016 14:37:18 +0900
parents 1873563e1ede
children ff7df4bb75de
files hgext/chgserver.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/chgserver.py	Sat Oct 15 14:24:29 2016 +0900
+++ b/hgext/chgserver.py	Sat Oct 15 14:37:18 2016 +0900
@@ -54,9 +54,7 @@
 
 from mercurial import (
     cmdutil,
-    commands,
     commandserver,
-    dispatch,
     error,
     extensions,
     osutil,
@@ -181,6 +179,8 @@
 
 # copied from hgext/pager.py:uisetup()
 def _setuppagercmd(ui, options, cmd):
+    from mercurial import commands  # avoid cycle
+
     if not ui.formatted():
         return
 
@@ -260,6 +260,8 @@
     return chgui(srcui)
 
 def _loadnewui(srcui, args):
+    from mercurial import dispatch  # avoid cycle
+
     newui = srcui.__class__()
     for a in ['fin', 'fout', 'ferr', 'environ']:
         setattr(newui, a, getattr(srcui, a))
@@ -439,6 +441,8 @@
         list, the client can continue with this server after completing all
         the instructions.
         """
+        from mercurial import dispatch  # avoid cycle
+
         args = self._readlist()
         try:
             self.ui, lui = _loadnewui(self.ui, args)
@@ -486,6 +490,8 @@
         If pager isn't enabled, this writes '\0' because channeledoutput
         does not allow to write empty data.
         """
+        from mercurial import dispatch  # avoid cycle
+
         args = self._readlist()
         try:
             cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,