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