# HG changeset patch # User Yuya Nishihara # Date 1476509838 -32400 # Node ID cc374292a561ffd54958a36e67a6bebbf575ad2f # Parent 1873563e1edefd35aac6d739ae0811cdbbb6927e 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. diff -r 1873563e1ede -r cc374292a561 hgext/chgserver.py --- 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,