2008-03-20 02:57:14 +03:00
|
|
|
# pager.py - display output using a pager
|
|
|
|
#
|
|
|
|
# Copyright 2008 David Soria Parra <dsp@php.net>
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms
|
|
|
|
# of the GNU General Public License, incorporated herein by reference.
|
|
|
|
#
|
2008-03-20 19:12:35 +03:00
|
|
|
# To load the extension, add it to your .hgrc file:
|
2008-03-20 02:57:14 +03:00
|
|
|
#
|
|
|
|
# [extension]
|
|
|
|
# hgext.pager =
|
|
|
|
#
|
2008-03-20 19:12:35 +03:00
|
|
|
# To set the pager that should be used, set the application variable:
|
2008-03-20 02:57:14 +03:00
|
|
|
#
|
|
|
|
# [pager]
|
2008-03-20 19:12:35 +03:00
|
|
|
# pager = LESS='FSRX' less
|
2008-03-20 02:57:14 +03:00
|
|
|
#
|
2008-03-20 19:12:35 +03:00
|
|
|
# If no pager is set, the pager extensions uses the environment
|
|
|
|
# variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager
|
|
|
|
# is used.
|
2008-03-20 02:57:14 +03:00
|
|
|
#
|
|
|
|
# If you notice "BROKEN PIPE" error messages, you can disable them
|
2008-03-20 19:12:35 +03:00
|
|
|
# by setting:
|
2008-03-20 02:57:14 +03:00
|
|
|
#
|
2008-03-20 19:12:35 +03:00
|
|
|
# [pager]
|
|
|
|
# quiet = True
|
2008-03-20 02:57:14 +03:00
|
|
|
|
|
|
|
import sys, os, signal
|
|
|
|
|
|
|
|
def uisetup(ui):
|
2008-03-20 19:12:35 +03:00
|
|
|
p = ui.config("pager", "pager", os.environ.get("PAGER"))
|
2008-04-03 13:11:31 +04:00
|
|
|
if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
|
2008-03-20 19:12:35 +03:00
|
|
|
if ui.configbool('pager', 'quiet'):
|
|
|
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
|
|
|
|
sys.stderr = sys.stdout = os.popen(p, "wb")
|