hgext/pager.py
author Matt Mackall <mpm@selenic.com>
Sun, 02 Jun 2013 16:22:51 -0500
changeset 19269 f4247d7e2046
parent 18923 d2647edb1782
child 19940 7d99bff0f77c
permissions -rw-r--r--
run-tests: move environment creation to a separate function
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     1
# pager.py - display output using a pager
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     2
#
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     3
# Copyright 2008 David Soria Parra <dsp@php.net>
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     4
#
8225
46293a0c7e9f updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents: 7995
diff changeset
     5
# This software may be used and distributed according to the terms of the
10263
25e572394f5c Update license to GPLv2+
Matt Mackall <mpm@selenic.com>
parents: 10112
diff changeset
     6
# GNU General Public License version 2 or any later version.
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     7
#
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 11414
diff changeset
     8
# To load the extension, add it to your configuration file:
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
     9
#
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
    10
#   [extension]
10112
703db37d186b hgext: enable extensions without "hgext." prefix in help texts
Martin Geisler <mg@lazybytes.net>
parents: 9841
diff changeset
    11
#   pager =
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
    12
#
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    13
# Run "hg help pager" to get info on configuration.
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    14
8894
868670dbc237 extensions: improve the consistency of synopses
Cédric Duval <cedricduval@free.fr>
parents: 8225
diff changeset
    15
'''browse command output with an external pager
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    16
9212
dfc1d5da98f0 pager: use reST syntax for literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9069
diff changeset
    17
To set the pager that should be used, set the application variable::
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    18
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    19
  [pager]
17305
e66fa4d587dc pager: drop -S option for less in example for pager configuration
Thomas Arendsen Hein <thomas@intevation.de>
parents: 17250
diff changeset
    20
  pager = less -FRX
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    21
9267
bd9e5d200186 pager: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9212
diff changeset
    22
If no pager is set, the pager extensions uses the environment variable
bd9e5d200186 pager: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9212
diff changeset
    23
$PAGER. If neither pager.pager, nor $PAGER is set, no pager is used.
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    24
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    25
You can disable the pager for certain commands by adding them to the
9212
dfc1d5da98f0 pager: use reST syntax for literal blocks
Martin Geisler <mg@lazybytes.net>
parents: 9069
diff changeset
    26
pager.ignore list::
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    27
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    28
  [pager]
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    29
  ignore = version, help, update
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    30
9267
bd9e5d200186 pager: wrap docstrings at 70 characters
Martin Geisler <mg@lazybytes.net>
parents: 9212
diff changeset
    31
You can also enable the pager only for certain commands using
9841
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
    32
pager.attend. Below is the default list of commands to be paged::
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    33
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    34
  [pager]
9841
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
    35
  attend = annotate, cat, diff, export, glog, log, qdiff
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
    36
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
    37
Setting pager.attend to an empty value will cause all commands to be
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
    38
paged.
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    39
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    40
If pager.attend is present, pager.ignore will be ignored.
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    41
10973
49a07f441496 Use hg role in help strings
Martin Geisler <mg@aragost.com>
parents: 10516
diff changeset
    42
To ignore global commands like :hg:`version` or :hg:`help`, you have
12083
ebfc46929f3e help: refer to user configuration file more consistently
Brodie Rao <brodie@bitheap.org>
parents: 11414
diff changeset
    43
to specify them in your user configuration file.
12694
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    44
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    45
The --pager=... option can also be used to control when the pager is
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    46
used. Use a boolean value like yes, no, on, off, or use auto for
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    47
normal behavior.
6462
6c4e12682fb9 pager: make config info accessible with "hg help pager"
Christian Ebert <blacktrash@gmx.net>
parents: 6457
diff changeset
    48
'''
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
    49
18923
d2647edb1782 pager: add missing imports of errno and shlex
Bryan O'Sullivan <bryano@fb.com>
parents: 18717
diff changeset
    50
import atexit, sys, os, signal, subprocess, errno, shlex
12694
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    51
from mercurial import commands, dispatch, util, extensions
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
    52
from mercurial.i18n import _
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
    53
16743
38caf405d010 hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents: 16652
diff changeset
    54
testedwith = 'internal'
38caf405d010 hgext: mark all first-party extensions as such
Augie Fackler <raf@durin42.com>
parents: 16652
diff changeset
    55
17250
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    56
def _pagerfork(ui, p):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    57
    if not util.safehasattr(os, 'fork'):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    58
        sys.stdout = util.popen(p, 'wb')
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    59
        if ui._isatty(sys.stderr):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    60
            sys.stderr = sys.stdout
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    61
        return
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    62
    fdin, fdout = os.pipe()
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    63
    pid = os.fork()
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    64
    if pid == 0:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    65
        os.close(fdin)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    66
        os.dup2(fdout, sys.stdout.fileno())
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    67
        if ui._isatty(sys.stderr):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    68
            os.dup2(fdout, sys.stderr.fileno())
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    69
        os.close(fdout)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    70
        return
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    71
    os.dup2(fdin, sys.stdin.fileno())
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    72
    os.close(fdin)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    73
    os.close(fdout)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    74
    try:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    75
        os.execvp('/bin/sh', ['/bin/sh', '-c', p])
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    76
    except OSError, e:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    77
        if e.errno == errno.ENOENT:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    78
            # no /bin/sh, try executing the pager directly
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    79
            args = shlex.split(p)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    80
            os.execvp(args[0], args)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    81
        else:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    82
            raise
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    83
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
    84
def _pagersubprocess(ui, p):
16631
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    85
    pager = subprocess.Popen(p, shell=True, bufsize=-1,
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    86
                             close_fds=util.closefds, stdin=subprocess.PIPE,
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    87
                             stdout=sys.stdout, stderr=sys.stderr)
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    88
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    89
    stdout = os.dup(sys.stdout.fileno())
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    90
    stderr = os.dup(sys.stderr.fileno())
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    91
    os.dup2(pager.stdin.fileno(), sys.stdout.fileno())
16752
359fda6cb01d pager: use ui._isatty infrastructure
Matt Mackall <mpm@selenic.com>
parents: 16743
diff changeset
    92
    if ui._isatty(sys.stderr):
16631
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    93
        os.dup2(pager.stdin.fileno(), sys.stderr.fileno())
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    94
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    95
    @atexit.register
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    96
    def killpager():
18717
fcc4b55876c3 pager: catch ctrl-c on exit (issue3834)
Matt Mackall <mpm@selenic.com>
parents: 17305
diff changeset
    97
        if util.safehasattr(signal, "SIGINT"):
fcc4b55876c3 pager: catch ctrl-c on exit (issue3834)
Matt Mackall <mpm@selenic.com>
parents: 17305
diff changeset
    98
            signal.signal(signal.SIGINT, signal.SIG_IGN)
16631
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
    99
        pager.stdin.close()
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
   100
        os.dup2(stdout, sys.stdout.fileno())
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
   101
        os.dup2(stderr, sys.stderr.fileno())
369741ef7253 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
Brodie Rao <brodie@sf.io>
parents: 14945
diff changeset
   102
        pager.wait()
11182
3c368a1c962d pager: fork and exec pager as parent process
Brodie Rao <brodie@bitheap.org>
parents: 10516
diff changeset
   103
17250
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   104
def _runpager(ui, p):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   105
    # The subprocess module shipped with Python <= 2.4 is buggy (issue3533).
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   106
    # The compat version is buggy on Windows (issue3225), but has been shipping
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   107
    # with hg for a long time.  Preserve existing functionality.
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   108
    if sys.version_info >= (2, 5):
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   109
        _pagersubprocess(ui, p)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   110
    else:
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   111
        _pagerfork(ui, p)
18f935b4c05a pager: work around bug in python 2.4's subprocess module (issue3533)
Michael Bacarella <mbacarella@janestreet.com>
parents: 16752
diff changeset
   112
6323
6e1308a09ffd Use the pager given by the environment to display long output
David Soria Parra <dsp@php.net>
parents:
diff changeset
   113
def uisetup(ui):
16752
359fda6cb01d pager: use ui._isatty infrastructure
Matt Mackall <mpm@selenic.com>
parents: 16743
diff changeset
   114
    if '--debugger' in sys.argv or not ui.formatted():
11414
0fa4474bdc2f pager: respect HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 11328
diff changeset
   115
        return
0fa4474bdc2f pager: respect HGPLAIN
Yuya Nishihara <yuya@tcha.org>
parents: 11328
diff changeset
   116
7216
292fb2ad2846 extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents: 6548
diff changeset
   117
    def pagecmd(orig, ui, options, cmd, cmdfunc):
6417
13fafd8cc4a1 pager: Add a configuration to enable/disable the pager for certain commands
David Soria Parra <dsp <at> php.net>
parents: 6324
diff changeset
   118
        p = ui.config("pager", "pager", os.environ.get("PAGER"))
14515
76f295eaed86 util: add helper function isatty(fd) to check for tty-ness
Idan Kamara <idankk86@gmail.com>
parents: 13642
diff changeset
   119
76f295eaed86 util: add helper function isatty(fd) to check for tty-ness
Idan Kamara <idankk86@gmail.com>
parents: 13642
diff changeset
   120
        if p:
9841
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
   121
            attend = ui.configlist('pager', 'attend', attended)
12694
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   122
            auto = options['pager'] == 'auto'
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   123
            always = util.parsebool(options['pager'])
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   124
            if (always or auto and
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   125
                (cmd in attend or
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   126
                 (cmd not in ui.configlist('pager', 'ignore') and not attend))):
11328
d357d147f0d4 pager: set ui.formatted() prior to redirecting stdout.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 11241
diff changeset
   127
                ui.setconfig('ui', 'formatted', ui.formatted())
10516
80a1161bc3b5 pager: set ui.interactive=False when enabled
Brodie Rao <me+hg@dackz.net>
parents: 10263
diff changeset
   128
                ui.setconfig('ui', 'interactive', False)
16652
2fdd1902ed2d pager: check if signal.SIGPIPE exists
David Soria Parra <dsp@php.net>
parents: 16632
diff changeset
   129
                if util.safehasattr(signal, "SIGPIPE"):
16632
0c0c1101e46d pager: remove quiet flag
David Soria Parra <dsp@php.net>
parents: 16631
diff changeset
   130
                    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
16752
359fda6cb01d pager: use ui._isatty infrastructure
Matt Mackall <mpm@selenic.com>
parents: 16743
diff changeset
   131
                _runpager(ui, p)
7216
292fb2ad2846 extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents: 6548
diff changeset
   132
        return orig(ui, options, cmd, cmdfunc)
6417
13fafd8cc4a1 pager: Add a configuration to enable/disable the pager for certain commands
David Soria Parra <dsp <at> php.net>
parents: 6324
diff changeset
   133
7216
292fb2ad2846 extensions: use new wrapper functions
Matt Mackall <mpm@selenic.com>
parents: 6548
diff changeset
   134
    extensions.wrapfunction(dispatch, '_runcommand', pagecmd)
9841
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
   135
12694
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   136
def extsetup(ui):
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   137
    commands.globalopts.append(
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   138
        ('', 'pager', 'auto',
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   139
         _("when to paginate (boolean, always, auto, or never)"),
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   140
         _('TYPE')))
04f6de46bf3a pager: add global --pager=<auto/boolean> option
Brodie Rao <brodie@bitheap.org>
parents: 12083
diff changeset
   141
9841
7cd6dee6fe37 pager: provide a default attend list
Brodie Rao <me+hg@dackz.net>
parents: 9267
diff changeset
   142
attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff']