Show More
@@ -1,60 +1,65 b'' | |||||
1 | # pager.py - display output using a pager |
|
1 | # pager.py - display output using a pager | |
2 | # |
|
2 | # | |
3 | # Copyright 2008 David Soria Parra <dsp@php.net> |
|
3 | # Copyright 2008 David Soria Parra <dsp@php.net> | |
4 | # |
|
4 | # | |
5 | # This software may be used and distributed according to the terms |
|
5 | # This software may be used and distributed according to the terms | |
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 | # |
|
7 | # | |
8 | # To load the extension, add it to your .hgrc file: |
|
8 | # To load the extension, add it to your .hgrc file: | |
9 | # |
|
9 | # | |
10 | # [extension] |
|
10 | # [extension] | |
11 | # hgext.pager = |
|
11 | # hgext.pager = | |
12 | # |
|
12 | # | |
13 | # To set the pager that should be used, set the application variable: |
|
13 | # Run "hg help pager" to get info on configuration. | |
14 | # |
|
14 | ||
15 | # [pager] |
|
15 | '''browse command output with external pager | |
16 | # pager = LESS='FSRX' less |
|
16 | ||
17 | # |
|
17 | To set the pager that should be used, set the application variable: | |
18 | # If no pager is set, the pager extensions uses the environment |
|
18 | ||
19 | # variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager |
|
19 | [pager] | |
20 | # is used. |
|
20 | pager = LESS='FSRX' less | |
21 | # |
|
21 | ||
22 | # If you notice "BROKEN PIPE" error messages, you can disable them |
|
22 | If no pager is set, the pager extensions uses the environment | |
23 | # by setting: |
|
23 | variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager | |
24 | # |
|
24 | is used. | |
25 | # [pager] |
|
25 | ||
26 | # quiet = True |
|
26 | If you notice "BROKEN PIPE" error messages, you can disable them | |
27 | # |
|
27 | by setting: | |
28 | # You can disable the pager for certain commands by adding them to the |
|
28 | ||
29 | # pager.ignore list: |
|
29 | [pager] | |
30 | # |
|
30 | quiet = True | |
31 | # [pager] |
|
31 | ||
32 | # ignore = version, help, update |
|
32 | You can disable the pager for certain commands by adding them to the | |
33 | # |
|
33 | pager.ignore list: | |
34 | # You can also enable the pager only for certain commands using pager.attend: |
|
34 | ||
35 | # |
|
35 | [pager] | |
36 | # [pager] |
|
36 | ignore = version, help, update | |
37 | # attend = log |
|
37 | ||
38 | # |
|
38 | You can also enable the pager only for certain commands using pager.attend: | |
39 | # If pager.attend is present, pager.ignore will be ignored. |
|
39 | ||
40 | # |
|
40 | [pager] | |
41 | # To ignore global commands like 'hg version' or 'hg help', you have to specify them |
|
41 | attend = log | |
42 | # in the global .hgrc |
|
42 | ||
|
43 | If pager.attend is present, pager.ignore will be ignored. | |||
|
44 | ||||
|
45 | To ignore global commands like "hg version" or "hg help", you have to specify | |||
|
46 | them in the global .hgrc | |||
|
47 | ''' | |||
43 |
|
48 | |||
44 | import sys, os, signal |
|
49 | import sys, os, signal | |
45 | from mercurial import dispatch |
|
50 | from mercurial import dispatch | |
46 |
|
51 | |||
47 | def uisetup(ui): |
|
52 | def uisetup(ui): | |
48 | def pagecmd(ui, options, cmd, cmdfunc): |
|
53 | def pagecmd(ui, options, cmd, cmdfunc): | |
49 | p = ui.config("pager", "pager", os.environ.get("PAGER")) |
|
54 | p = ui.config("pager", "pager", os.environ.get("PAGER")) | |
50 | if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |
|
55 | if p and sys.stdout.isatty() and '--debugger' not in sys.argv: | |
51 | attend = ui.configlist('pager', 'attend') |
|
56 | attend = ui.configlist('pager', 'attend') | |
52 | if (cmd in attend or |
|
57 | if (cmd in attend or | |
53 | (cmd not in ui.configlist('pager', 'ignore') and not attend)): |
|
58 | (cmd not in ui.configlist('pager', 'ignore') and not attend)): | |
54 | sys.stderr = sys.stdout = os.popen(p, "wb") |
|
59 | sys.stderr = sys.stdout = os.popen(p, "wb") | |
55 | if ui.configbool('pager', 'quiet'): |
|
60 | if ui.configbool('pager', 'quiet'): | |
56 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
61 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) | |
57 | return oldrun(ui, options, cmd, cmdfunc) |
|
62 | return oldrun(ui, options, cmd, cmdfunc) | |
58 |
|
63 | |||
59 | oldrun = dispatch._runcommand |
|
64 | oldrun = dispatch._runcommand | |
60 | dispatch._runcommand = pagecmd |
|
65 | dispatch._runcommand = pagecmd |
General Comments 0
You need to be logged in to leave comments.
Login now