changeset 30741:fde9692a02c0

chg: remove getpager support We have enough bits to switch to the new chg pager code path in runcommand. So just remove the legacy getpager support. This is a red-only patch, and will break chg's pager support temporarily.
author Jun Wu <quark@fb.com>
date Tue, 10 Jan 2017 06:59:39 +0800
parents 493935e0327a
children d3e2d39b97ea
files contrib/chg/chg.c contrib/chg/hgclient.c contrib/chg/hgclient.h mercurial/chgserver.py
diffstat 4 files changed, 0 insertions(+), 109 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/chg/chg.c	Tue Jan 10 06:59:31 2017 +0800
+++ b/contrib/chg/chg.c	Tue Jan 10 06:59:39 2017 +0800
@@ -429,10 +429,6 @@
 	}
 
 	setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
-	const char *pagercmd = hgc_getpager(hgc, argv + 1, argc - 1);
-	pid_t pagerpid = setuppager(pagercmd);
-	if (pagerpid)
-		hgc_attachio(hgc);  /* reattach to pager */
 	int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);
 	restoresignalhandler();
 	hgc_close(hgc);
--- a/contrib/chg/hgclient.c	Tue Jan 10 06:59:31 2017 +0800
+++ b/contrib/chg/hgclient.c	Tue Jan 10 06:59:39 2017 +0800
@@ -32,7 +32,6 @@
 	/* cHg extension: */
 	CAP_ATTACHIO = 0x0100,
 	CAP_CHDIR = 0x0200,
-	CAP_GETPAGER = 0x0400,
 	CAP_SETENV = 0x0800,
 	CAP_SETUMASK = 0x1000,
 	CAP_VALIDATE = 0x2000,
@@ -48,7 +47,6 @@
 	{"runcommand", CAP_RUNCOMMAND},
 	{"attachio", CAP_ATTACHIO},
 	{"chdir", CAP_CHDIR},
-	{"getpager", CAP_GETPAGER},
 	{"setenv", CAP_SETENV},
 	{"setumask", CAP_SETUMASK},
 	{"validate", CAP_VALIDATE},
@@ -593,31 +591,6 @@
 }
 
 /*!
- * Get pager command for the given Mercurial command args
- *
- * If no pager enabled, returns NULL. The return value becomes invalid
- * once you run another request to hgc.
- */
-const char *hgc_getpager(hgclient_t *hgc, const char *const args[],
-			 size_t argsize)
-{
-	assert(hgc);
-
-	if (!(hgc->capflags & CAP_GETPAGER))
-		return NULL;
-
-	packcmdargs(&hgc->ctx, args, argsize);
-	writeblockrequest(hgc, "getpager");
-	handleresponse(hgc);
-
-	if (hgc->ctx.datasize < 1 || hgc->ctx.data[0] == '\0')
-		return NULL;
-	enlargecontext(&hgc->ctx, hgc->ctx.datasize + 1);
-	hgc->ctx.data[hgc->ctx.datasize] = '\0';
-	return hgc->ctx.data;
-}
-
-/*!
  * Update server's environment variables
  *
  * @param envp  list of environment variables in "NAME=VALUE" format,
--- a/contrib/chg/hgclient.h	Tue Jan 10 06:59:31 2017 +0800
+++ b/contrib/chg/hgclient.h	Tue Jan 10 06:59:39 2017 +0800
@@ -25,8 +25,6 @@
 			  size_t argsize);
 int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize);
 void hgc_attachio(hgclient_t *hgc);
-const char *hgc_getpager(hgclient_t *hgc, const char *const args[],
-			 size_t argsize);
 void hgc_setenv(hgclient_t *hgc, const char *const envp[]);
 
 #endif  /* HGCLIENT_H_ */
--- a/mercurial/chgserver.py	Tue Jan 10 06:59:31 2017 +0800
+++ b/mercurial/chgserver.py	Tue Jan 10 06:59:39 2017 +0800
@@ -16,9 +16,6 @@
 'chdir' command
     change current directory
 
-'getpager' command
-    checks if pager is enabled and which pager should be executed
-
 'setenv' command
     replace os.environ completely
 
@@ -45,14 +42,12 @@
 import inspect
 import os
 import re
-import signal
 import struct
 import time
 
 from .i18n import _
 
 from . import (
-    cmdutil,
     commandserver,
     encoding,
     error,
@@ -172,45 +167,6 @@
         _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash))
         return hashstate(confighash, mtimehash, mtimepaths)
 
-# copied from hgext/pager.py:uisetup()
-def _setuppagercmd(ui, options, cmd):
-    from . import commands  # avoid cycle
-
-    if not ui.formatted():
-        return
-
-    p = ui.config("pager", "pager", encoding.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, attachio):
     class chgui(srcui.__class__):
         def __init__(self, src=None):
@@ -484,37 +440,6 @@
         _log('setumask %r\n' % mask)
         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.
-        """
-        from . import dispatch  # avoid cycle
-
-        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 runcommand(self):
         return super(chgcmdserver, self).runcommand()
 
@@ -535,7 +460,6 @@
     capabilities = commandserver.server.capabilities.copy()
     capabilities.update({'attachio': attachio,
                          'chdir': chdir,
-                         'getpager': getpager,
                          'runcommand': runcommand,
                          'setenv': setenv,
                          'setumask': setumask})