Patchwork [6,of,8] chgserver: implement chgui._runpager

login
register
mail settings
Submitter Jun Wu
Date Jan. 9, 2017, 11:12 p.m.
Message ID <e44b1d6deadb67908b43.1484003546@x1c>
Download mbox | patch
Permalink /patch/18158/
State Accepted
Headers show

Comments

Jun Wu - Jan. 9, 2017, 11:12 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1484002771 -28800
#      Tue Jan 10 06:59:31 2017 +0800
# Node ID e44b1d6deadb67908b43909ad920572e3efa38e6
# Parent  24ebef0f19843c6b1b8fbf32d99a7e8dba2fb734
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r e44b1d6deadb
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.

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -212,5 +212,5 @@  def _setuppagercmd(ui, options, cmd):
         return p
 
-def _newchgui(srcui, csystem):
+def _newchgui(srcui, csystem, attachio):
     class chgui(srcui.__class__):
         def __init__(self, src=None):
@@ -242,4 +242,8 @@  def _newchgui(srcui, csystem):
             return rc
 
+        def _runpager(self, cmd):
+            self._csystem(cmd, util.shellenviron(), type='pager',
+                          cmdtable={'attachio': attachio})
+
     return chgui(srcui)
 
@@ -336,5 +340,6 @@  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"