hgext/chgserver.py
changeset 30512 cc374292a561
parent 30511 1873563e1ede
equal deleted inserted replaced
30511:1873563e1ede 30512:cc374292a561
    52 
    52 
    53 from mercurial.i18n import _
    53 from mercurial.i18n import _
    54 
    54 
    55 from mercurial import (
    55 from mercurial import (
    56     cmdutil,
    56     cmdutil,
    57     commands,
       
    58     commandserver,
    57     commandserver,
    59     dispatch,
       
    60     error,
    58     error,
    61     extensions,
    59     extensions,
    62     osutil,
    60     osutil,
    63     server,
    61     server,
    64     util,
    62     util,
   179         _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash))
   177         _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash))
   180         return hashstate(confighash, mtimehash, mtimepaths)
   178         return hashstate(confighash, mtimehash, mtimepaths)
   181 
   179 
   182 # copied from hgext/pager.py:uisetup()
   180 # copied from hgext/pager.py:uisetup()
   183 def _setuppagercmd(ui, options, cmd):
   181 def _setuppagercmd(ui, options, cmd):
       
   182     from mercurial import commands  # avoid cycle
       
   183 
   184     if not ui.formatted():
   184     if not ui.formatted():
   185         return
   185         return
   186 
   186 
   187     p = ui.config("pager", "pager", os.environ.get("PAGER"))
   187     p = ui.config("pager", "pager", os.environ.get("PAGER"))
   188     usepager = False
   188     usepager = False
   258             return rc
   258             return rc
   259 
   259 
   260     return chgui(srcui)
   260     return chgui(srcui)
   261 
   261 
   262 def _loadnewui(srcui, args):
   262 def _loadnewui(srcui, args):
       
   263     from mercurial import dispatch  # avoid cycle
       
   264 
   263     newui = srcui.__class__()
   265     newui = srcui.__class__()
   264     for a in ['fin', 'fout', 'ferr', 'environ']:
   266     for a in ['fin', 'fout', 'ferr', 'environ']:
   265         setattr(newui, a, getattr(srcui, a))
   267         setattr(newui, a, getattr(srcui, a))
   266     if util.safehasattr(srcui, '_csystem'):
   268     if util.safehasattr(srcui, '_csystem'):
   267         newui._csystem = srcui._csystem
   269         newui._csystem = srcui._csystem
   437               reconnect.
   439               reconnect.
   438         If neither "reconnect" nor "redirect" is included in the instruction
   440         If neither "reconnect" nor "redirect" is included in the instruction
   439         list, the client can continue with this server after completing all
   441         list, the client can continue with this server after completing all
   440         the instructions.
   442         the instructions.
   441         """
   443         """
       
   444         from mercurial import dispatch  # avoid cycle
       
   445 
   442         args = self._readlist()
   446         args = self._readlist()
   443         try:
   447         try:
   444             self.ui, lui = _loadnewui(self.ui, args)
   448             self.ui, lui = _loadnewui(self.ui, args)
   445         except error.ParseError as inst:
   449         except error.ParseError as inst:
   446             dispatch._formatparse(self.ui.warn, inst)
   450             dispatch._formatparse(self.ui.warn, inst)
   484         """Read cmdargs and write pager command to r-channel if enabled
   488         """Read cmdargs and write pager command to r-channel if enabled
   485 
   489 
   486         If pager isn't enabled, this writes '\0' because channeledoutput
   490         If pager isn't enabled, this writes '\0' because channeledoutput
   487         does not allow to write empty data.
   491         does not allow to write empty data.
   488         """
   492         """
       
   493         from mercurial import dispatch  # avoid cycle
       
   494 
   489         args = self._readlist()
   495         args = self._readlist()
   490         try:
   496         try:
   491             cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,
   497             cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,
   492                                                                      args)
   498                                                                      args)
   493         except (error.Abort, error.AmbiguousCommand, error.CommandError,
   499         except (error.Abort, error.AmbiguousCommand, error.CommandError,