##// END OF EJS Templates
chg: remove getpager support...
Jun Wu -
r30741:fde9692a default
parent child Browse files
Show More
@@ -429,10 +429,6 b' int main(int argc, const char *argv[], c'
429 429 }
430 430
431 431 setupsignalhandler(hgc_peerpid(hgc), hgc_peerpgid(hgc));
432 const char *pagercmd = hgc_getpager(hgc, argv + 1, argc - 1);
433 pid_t pagerpid = setuppager(pagercmd);
434 if (pagerpid)
435 hgc_attachio(hgc); /* reattach to pager */
436 432 int exitcode = hgc_runcommand(hgc, argv + 1, argc - 1);
437 433 restoresignalhandler();
438 434 hgc_close(hgc);
@@ -32,7 +32,6 b' enum {'
32 32 /* cHg extension: */
33 33 CAP_ATTACHIO = 0x0100,
34 34 CAP_CHDIR = 0x0200,
35 CAP_GETPAGER = 0x0400,
36 35 CAP_SETENV = 0x0800,
37 36 CAP_SETUMASK = 0x1000,
38 37 CAP_VALIDATE = 0x2000,
@@ -48,7 +47,6 b' static const cappair_t captable[] = {'
48 47 {"runcommand", CAP_RUNCOMMAND},
49 48 {"attachio", CAP_ATTACHIO},
50 49 {"chdir", CAP_CHDIR},
51 {"getpager", CAP_GETPAGER},
52 50 {"setenv", CAP_SETENV},
53 51 {"setumask", CAP_SETUMASK},
54 52 {"validate", CAP_VALIDATE},
@@ -593,31 +591,6 b' void hgc_attachio(hgclient_t *hgc)'
593 591 }
594 592
595 593 /*!
596 * Get pager command for the given Mercurial command args
597 *
598 * If no pager enabled, returns NULL. The return value becomes invalid
599 * once you run another request to hgc.
600 */
601 const char *hgc_getpager(hgclient_t *hgc, const char *const args[],
602 size_t argsize)
603 {
604 assert(hgc);
605
606 if (!(hgc->capflags & CAP_GETPAGER))
607 return NULL;
608
609 packcmdargs(&hgc->ctx, args, argsize);
610 writeblockrequest(hgc, "getpager");
611 handleresponse(hgc);
612
613 if (hgc->ctx.datasize < 1 || hgc->ctx.data[0] == '\0')
614 return NULL;
615 enlargecontext(&hgc->ctx, hgc->ctx.datasize + 1);
616 hgc->ctx.data[hgc->ctx.datasize] = '\0';
617 return hgc->ctx.data;
618 }
619
620 /*!
621 594 * Update server's environment variables
622 595 *
623 596 * @param envp list of environment variables in "NAME=VALUE" format,
@@ -25,8 +25,6 b' const char **hgc_validate(hgclient_t *hg'
25 25 size_t argsize);
26 26 int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize);
27 27 void hgc_attachio(hgclient_t *hgc);
28 const char *hgc_getpager(hgclient_t *hgc, const char *const args[],
29 size_t argsize);
30 28 void hgc_setenv(hgclient_t *hgc, const char *const envp[]);
31 29
32 30 #endif /* HGCLIENT_H_ */
@@ -16,9 +16,6 b''
16 16 'chdir' command
17 17 change current directory
18 18
19 'getpager' command
20 checks if pager is enabled and which pager should be executed
21
22 19 'setenv' command
23 20 replace os.environ completely
24 21
@@ -45,14 +42,12 b' import hashlib'
45 42 import inspect
46 43 import os
47 44 import re
48 import signal
49 45 import struct
50 46 import time
51 47
52 48 from .i18n import _
53 49
54 50 from . import (
55 cmdutil,
56 51 commandserver,
57 52 encoding,
58 53 error,
@@ -172,45 +167,6 b' class hashstate(object):'
172 167 _log('confighash = %s mtimehash = %s\n' % (confighash, mtimehash))
173 168 return hashstate(confighash, mtimehash, mtimepaths)
174 169
175 # copied from hgext/pager.py:uisetup()
176 def _setuppagercmd(ui, options, cmd):
177 from . import commands # avoid cycle
178
179 if not ui.formatted():
180 return
181
182 p = ui.config("pager", "pager", encoding.environ.get("PAGER"))
183 usepager = False
184 always = util.parsebool(options['pager'])
185 auto = options['pager'] == 'auto'
186
187 if not p:
188 pass
189 elif always:
190 usepager = True
191 elif not auto:
192 usepager = False
193 else:
194 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']
195 attend = ui.configlist('pager', 'attend', attended)
196 ignore = ui.configlist('pager', 'ignore')
197 cmds, _ = cmdutil.findcmd(cmd, commands.table)
198
199 for cmd in cmds:
200 var = 'attend-%s' % cmd
201 if ui.config('pager', var):
202 usepager = ui.configbool('pager', var)
203 break
204 if (cmd in attend or
205 (cmd not in ignore and not attend)):
206 usepager = True
207 break
208
209 if usepager:
210 ui.setconfig('ui', 'formatted', ui.formatted(), 'pager')
211 ui.setconfig('ui', 'interactive', False, 'pager')
212 return p
213
214 170 def _newchgui(srcui, csystem, attachio):
215 171 class chgui(srcui.__class__):
216 172 def __init__(self, src=None):
@@ -484,37 +440,6 b' class chgcmdserver(commandserver.server)'
484 440 _log('setumask %r\n' % mask)
485 441 os.umask(mask)
486 442
487 def getpager(self):
488 """Read cmdargs and write pager command to r-channel if enabled
489
490 If pager isn't enabled, this writes '\0' because channeledoutput
491 does not allow to write empty data.
492 """
493 from . import dispatch # avoid cycle
494
495 args = self._readlist()
496 try:
497 cmd, _func, args, options, _cmdoptions = dispatch._parse(self.ui,
498 args)
499 except (error.Abort, error.AmbiguousCommand, error.CommandError,
500 error.UnknownCommand):
501 cmd = None
502 options = {}
503 if not cmd or 'pager' not in options:
504 self.cresult.write('\0')
505 return
506
507 pagercmd = _setuppagercmd(self.ui, options, cmd)
508 if pagercmd:
509 # Python's SIGPIPE is SIG_IGN by default. change to SIG_DFL so
510 # we can exit if the pipe to the pager is closed
511 if util.safehasattr(signal, 'SIGPIPE') and \
512 signal.getsignal(signal.SIGPIPE) == signal.SIG_IGN:
513 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
514 self.cresult.write(pagercmd)
515 else:
516 self.cresult.write('\0')
517
518 443 def runcommand(self):
519 444 return super(chgcmdserver, self).runcommand()
520 445
@@ -535,7 +460,6 b' class chgcmdserver(commandserver.server)'
535 460 capabilities = commandserver.server.capabilities.copy()
536 461 capabilities.update({'attachio': attachio,
537 462 'chdir': chdir,
538 'getpager': getpager,
539 463 'runcommand': runcommand,
540 464 'setenv': setenv,
541 465 'setumask': setumask})
General Comments 0
You need to be logged in to leave comments. Login now