Mercurial > hg
changeset 11186:a890cc501501
Merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 16 May 2010 14:38:32 -0500 |
parents | 6d7cf82453be (current diff) 3c368a1c962d (diff) |
children | 3ef2572de32f |
files | hgext/color.py hgext/pager.py |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/pager.py Sat May 15 23:33:22 2010 -0400 +++ b/hgext/pager.py Sun May 16 14:38:32 2010 -0500 @@ -49,9 +49,27 @@ to specify them in the global .hgrc ''' -import sys, os, signal +import sys, os, signal, shlex from mercurial import dispatch, util, extensions +def _runpager(p): + if not hasattr(os, 'fork'): + sys.stderr = sys.stdout = util.popen(p, 'wb') + return + fdin, fdout = os.pipe() + pid = os.fork() + if pid == 0: + os.close(fdin) + os.dup2(fdout, sys.stdout.fileno()) + os.dup2(fdout, sys.stderr.fileno()) + os.close(fdout) + return + os.dup2(fdin, sys.stdin.fileno()) + os.close(fdin) + os.close(fdout) + args = shlex.split(p) + os.execvp(args[0], args) + def uisetup(ui): def pagecmd(orig, ui, options, cmd, cmdfunc): p = ui.config("pager", "pager", os.environ.get("PAGER")) @@ -60,7 +78,7 @@ if (cmd in attend or (cmd not in ui.configlist('pager', 'ignore') and not attend)): ui.setconfig('ui', 'interactive', False) - sys.stderr = sys.stdout = util.popen(p, "wb") + _runpager(p) if ui.configbool('pager', 'quiet'): signal.signal(signal.SIGPIPE, signal.SIG_DFL) return orig(ui, options, cmd, cmdfunc)