Patchwork [6,of,9] chgserver: remove getpager command

login
register
mail settings
Submitter Jun Wu
Date Nov. 13, 2016, 9:55 p.m.
Message ID <2b3091653f9a1f5ed2ca.1479074150@x1c>
Download mbox | patch
Permalink /patch/17555/
State Changes Requested
Headers show

Comments

Jun Wu - Nov. 13, 2016, 9:55 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1479072035 0
#      Sun Nov 13 21:20:35 2016 +0000
# Node ID 2b3091653f9a1f5ed2caef4b7205e5e6dacdad30
# Parent  76abed25eed8358e6742e20018ab612bd0ec7e99
chgserver: remove getpager command

Since we don't run "uisetup" of the pager extension, "getpager" will just
return nothing. We are going to send the pager command via channeledsystem
instead.

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -17,7 +17,4 @@ 
     change current directory
 
-'getpager' command
-    checks if pager is enabled and which pager should be executed
-
 'setenv' command
     replace os.environ completely
@@ -46,5 +43,4 @@  import inspect
 import os
 import re
-import signal
 import struct
 import sys
@@ -55,5 +51,4 @@  from .i18n import _
 from . import (
     cmdutil,
-    commands,
     commandserver,
     dispatch,
@@ -201,41 +196,4 @@  class hashstate(object):
         return hashstate(confighash, mtimehash, mtimepaths)
 
-# copied from hgext/pager.py:uisetup()
-def _setuppagercmd(ui, options, cmd):
-    if not ui.formatted():
-        return
-
-    p = ui.config("pager", "pager", os.environ.get("PAGER"))
-    usepager = False
-    always = util.parsebool(options['pager'])
-    auto = options['pager'] == 'auto'
-
-    if not p:
-        pass
-    elif always:
-        usepager = True
-    elif not auto:
-        usepager = False
-    else:
-        attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
-        attend = ui.configlist('pager', 'attend', attended)
-        ignore = ui.configlist('pager', 'ignore')
-        cmds, _ = cmdutil.findcmd(cmd, commands.table)
-
-        for cmd in cmds:
-            var = 'attend-%s' % cmd
-            if ui.config('pager', var):
-                usepager = ui.configbool('pager', var)
-                break
-            if (cmd in attend or
-                (cmd not in ignore and not attend)):
-                usepager = True
-                break
-
-    if usepager:
-        ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
-        ui.setconfig('ui', 'interactive', False, 'pager')
-        return p
-
 def _newchgui(srcui, csystem):
     class chgui(srcui.__class__):
@@ -502,33 +460,4 @@  class chgcmdserver(commandserver.server)
         os.umask(mask)
 
-    def getpager(self):
-        """Read cmdargs and write pager command to r-channel if enabled
-
-        If pager isn't enabled, this writes '\0' because channeledoutput
-        does not allow to write empty data.
-        """
-        args = self._readlist()
-        try:
-            cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,
-                                                                     args)
-        except (error.Abort, error.AmbiguousCommand, error.CommandError,
-                error.UnknownCommand):
-            cmd = None
-            options = {}
-        if not cmd or 'pager' not in options:
-            self.cresult.write('\0')
-            return
-
-        pagercmd = _setuppagercmd(self.ui, options, cmd)
-        if pagercmd:
-            # Python's SIGPIPE is SIG_IGN by default. change to SIG_DFL so
-            # we can exit if the pipe to the pager is closed
-            if util.safehasattr(signal, 'SIGPIPE') and \
-                    signal.getsignal(signal.SIGPIPE) == signal.SIG_IGN:
-                signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-            self.cresult.write(pagercmd)
-        else:
-            self.cresult.write('\0')
-
     def setenv(self):
         """Clear and update os.environ
@@ -548,5 +477,4 @@  class chgcmdserver(commandserver.server)
     capabilities.update({'attachio': attachio,
                          'chdir': chdir,
-                         'getpager': getpager,
                          'setenv': setenv,
                          'setumask': setumask})