Show More
@@ -1,82 +1,82 b'' | |||
|
1 | 1 | # pager.py - display output using a pager |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2008 David Soria Parra <dsp@php.net> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | # |
|
8 | 8 | # To load the extension, add it to your configuration file: |
|
9 | 9 | # |
|
10 | 10 | # [extension] |
|
11 | 11 | # pager = |
|
12 | 12 | # |
|
13 | 13 | # Run 'hg help pager' to get info on configuration. |
|
14 | 14 | |
|
15 | 15 | '''browse command output with an external pager (DEPRECATED) |
|
16 | 16 | |
|
17 | 17 | Forcibly enable paging for individual commands that don't typically |
|
18 | 18 | request pagination with the attend-<command> option. This setting |
|
19 | 19 | takes precedence over ignore options and defaults:: |
|
20 | 20 | |
|
21 | 21 | [pager] |
|
22 | 22 | attend-cat = false |
|
23 | 23 | ''' |
|
24 | 24 | |
|
25 | 25 | from mercurial import ( |
|
26 | 26 | cmdutil, |
|
27 | 27 | commands, |
|
28 | 28 | dispatch, |
|
29 | 29 | extensions, |
|
30 | 30 | registrar, |
|
31 | 31 | ) |
|
32 | 32 | |
|
33 | 33 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
34 | 34 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
35 | 35 | # be specifying the version(s) of Mercurial they are tested with, or |
|
36 | 36 | # leave the attribute unspecified. |
|
37 | 37 | testedwith = b'ships-with-hg-core' |
|
38 | 38 | |
|
39 | 39 | configtable = {} |
|
40 | 40 | configitem = registrar.configitem(configtable) |
|
41 | 41 | |
|
42 | 42 | configitem( |
|
43 | 43 | b'pager', |
|
44 | 44 | b'attend', |
|
45 | 45 | default=lambda: attended, |
|
46 | 46 | ) |
|
47 | 47 | |
|
48 | 48 | |
|
49 | 49 | def uisetup(ui): |
|
50 | 50 | def pagecmd(orig, ui, options, cmd, cmdfunc): |
|
51 | 51 | auto = options[b'pager'] == b'auto' |
|
52 | 52 | if auto and not ui.pageractive: |
|
53 | 53 | usepager = False |
|
54 | 54 | attend = ui.configlist(b'pager', b'attend') |
|
55 | 55 | ignore = ui.configlist(b'pager', b'ignore') |
|
56 | 56 | cmds, _ = cmdutil.findcmd(cmd, commands.table) |
|
57 | 57 | |
|
58 | 58 | for cmd in cmds: |
|
59 | 59 | var = b'attend-%s' % cmd |
|
60 | 60 | if ui.config(b'pager', var, None): |
|
61 | 61 | usepager = ui.configbool(b'pager', var, True) |
|
62 | 62 | break |
|
63 | 63 | if cmd in attend or (cmd not in ignore and not attend): |
|
64 | 64 | usepager = True |
|
65 | 65 | break |
|
66 | 66 | |
|
67 | 67 | if usepager: |
|
68 | 68 | # Slight hack: the attend list is supposed to override |
|
69 | 69 | # the ignore list for the pager extension, but the |
|
70 | 70 | # core code doesn't know about attend, so we have to |
|
71 | 71 | # lobotomize the ignore list so that the extension's |
|
72 | 72 | # behavior is preserved. |
|
73 | 73 | ui.setconfig(b'pager', b'ignore', b'', b'pager') |
|
74 | 74 | ui.pager(b'extension-via-attend-' + cmd) |
|
75 | 75 | else: |
|
76 | 76 | ui.disablepager() |
|
77 | 77 | return orig(ui, options, cmd, cmdfunc) |
|
78 | 78 | |
|
79 |
extensions.wrapfunction(dispatch, |
|
|
79 | extensions.wrapfunction(dispatch, '_runcommand', pagecmd) | |
|
80 | 80 | |
|
81 | 81 | |
|
82 | 82 | attended = [b'annotate', b'cat', b'diff', b'export', b'glog', b'log', b'qdiff'] |
General Comments 0
You need to be logged in to leave comments.
Login now