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.
--- a/mercurial/chgserver.py Tue Jan 10 06:59:21 2017 +0800
+++ b/mercurial/chgserver.py Tue Jan 10 06:59:31 2017 +0800
@@ -211,7 +211,7 @@
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 @@
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 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