# HG changeset patch # User Jun Wu # Date 2017-01-09 22:59:31 # Node ID 493935e0327a2dca0987a702bf06fa89b62e6a5c # Parent 815e1cefd0826e6f63e546b94967a135e2cbba81 chgserver: implement chgui._runpager This patch implements chgui._runpager in a relatively simple way. A more clean way is to move the core logic of "attachio" to "ui", which will be done later after chg runs uisetup per request. diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -211,7 +211,7 @@ def _setuppagercmd(ui, options, cmd): ui.setconfig('ui', 'interactive', False, 'pager') return p -def _newchgui(srcui, csystem): +def _newchgui(srcui, csystem, attachio): class chgui(srcui.__class__): def __init__(self, src=None): super(chgui, self).__init__(src) @@ -241,6 +241,10 @@ def _newchgui(srcui, csystem): raise onerr(errmsg) return rc + def _runpager(self, cmd): + self._csystem(cmd, util.shellenviron(), type='pager', + cmdtable={'attachio': attachio}) + return chgui(srcui) def _loadnewui(srcui, args): @@ -335,7 +339,8 @@ class channeledsystem(object): class chgcmdserver(commandserver.server): def __init__(self, ui, repo, fin, fout, sock, hashstate, baseaddress): super(chgcmdserver, self).__init__( - _newchgui(ui, channeledsystem(fin, fout, 'S')), repo, fin, fout) + _newchgui(ui, channeledsystem(fin, fout, 'S'), self.attachio), + repo, fin, fout) self.clientsock = sock self._oldios = [] # original (self.ch, ui.fp, fd) before "attachio" self.hashstate = hashstate