Show More
@@ -5,50 +5,31 | |||||
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 | # To set the pager that should be used, set the application variable: | |
14 | # |
|
|||
15 | # [pager] |
|
|||
16 | # application = less |
|
|||
17 | # |
|
|||
18 | # You can also set environment variables there |
|
|||
19 | # |
|
14 | # | |
20 | # [pager] |
|
15 | # [pager] | |
21 |
# |
|
16 | # pager = LESS='FSRX' less | |
22 | # |
|
17 | # | |
23 |
# If no |
|
18 | # If no pager is set, the pager extensions uses the environment | |
24 |
# variable $PAGER. If neither pager. |
|
19 | # variable $PAGER. If neither pager.pager, nor $PAGER is set, no pager | |
25 | # $PAGER is set, no pager is used. |
|
20 | # is used. | |
26 | # |
|
21 | # | |
27 | # If you notice "BROKEN PIPE" error messages, you can disable them |
|
22 | # If you notice "BROKEN PIPE" error messages, you can disable them | |
28 | # by setting |
|
23 | # by setting: | |
29 | # |
|
24 | # | |
30 | # [pager] |
|
25 | # [pager] | |
31 | # quiet = True |
|
26 | # quiet = True | |
32 | # |
|
|||
33 |
|
27 | |||
34 | import sys, os, signal |
|
28 | import sys, os, signal | |
35 |
|
29 | |||
36 | def getpager(ui): |
|
|||
37 | '''return a pager |
|
|||
38 |
|
||||
39 | We separate this method from the pager class as we don't want to |
|
|||
40 | instantiate a pager if it is not used at all |
|
|||
41 | ''' |
|
|||
42 | if sys.stdout.isatty(): |
|
|||
43 | return (ui.config("pager", "application") |
|
|||
44 | or os.environ.get("PAGER")) |
|
|||
45 |
|
||||
46 | def uisetup(ui): |
|
30 | def uisetup(ui): | |
47 | # disable broken pipe error messages |
|
31 | p = ui.config("pager", "pager", os.environ.get("PAGER")) | |
48 | if ui.configbool('pager', 'quiet', False): |
|
32 | if p and sys.stdout.isatty(): | |
49 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
|
33 | if ui.configbool('pager', 'quiet'): | |
50 |
|
34 | signal.signal(signal.SIGPIPE, signal.SIG_DFL) | ||
51 | if getpager(ui): |
|
35 | sys.stderr = sys.stdout = os.popen(p, "wb") | |
52 | pager = os.popen(getpager(ui), 'wb') |
|
|||
53 | sys.stderr = pager |
|
|||
54 | sys.stdout = pager |
|
General Comments 0
You need to be logged in to leave comments.
Login now