Mercurial > hg
comparison hgext/pager.py @ 9841:7cd6dee6fe37
pager: provide a default attend list
The default list includes commands which normally print large amounts of
text. This should be more user-friendly than paging all commands by default,
which can be confusing when the pager swallows input prompts (with, e.g.,
record, merge, HTTP/SSH authentication, etc.)
author | Brodie Rao <me+hg@dackz.net> |
---|---|
date | Thu, 12 Nov 2009 10:29:40 -0500 |
parents | bd9e5d200186 |
children | 703db37d186b |
comparison
equal
deleted
inserted
replaced
9840:18d5935c0c62 | 9841:7cd6dee6fe37 |
---|---|
33 | 33 |
34 [pager] | 34 [pager] |
35 ignore = version, help, update | 35 ignore = version, help, update |
36 | 36 |
37 You can also enable the pager only for certain commands using | 37 You can also enable the pager only for certain commands using |
38 pager.attend:: | 38 pager.attend. Below is the default list of commands to be paged:: |
39 | 39 |
40 [pager] | 40 [pager] |
41 attend = log | 41 attend = annotate, cat, diff, export, glog, log, qdiff |
42 | |
43 Setting pager.attend to an empty value will cause all commands to be | |
44 paged. | |
42 | 45 |
43 If pager.attend is present, pager.ignore will be ignored. | 46 If pager.attend is present, pager.ignore will be ignored. |
44 | 47 |
45 To ignore global commands like "hg version" or "hg help", you have to | 48 To ignore global commands like "hg version" or "hg help", you have to |
46 specify them in the global .hgrc | 49 specify them in the global .hgrc |
51 | 54 |
52 def uisetup(ui): | 55 def uisetup(ui): |
53 def pagecmd(orig, ui, options, cmd, cmdfunc): | 56 def pagecmd(orig, ui, options, cmd, cmdfunc): |
54 p = ui.config("pager", "pager", os.environ.get("PAGER")) | 57 p = ui.config("pager", "pager", os.environ.get("PAGER")) |
55 if p and sys.stdout.isatty() and '--debugger' not in sys.argv: | 58 if p and sys.stdout.isatty() and '--debugger' not in sys.argv: |
56 attend = ui.configlist('pager', 'attend') | 59 attend = ui.configlist('pager', 'attend', attended) |
57 if (cmd in attend or | 60 if (cmd in attend or |
58 (cmd not in ui.configlist('pager', 'ignore') and not attend)): | 61 (cmd not in ui.configlist('pager', 'ignore') and not attend)): |
59 sys.stderr = sys.stdout = util.popen(p, "wb") | 62 sys.stderr = sys.stdout = util.popen(p, "wb") |
60 if ui.configbool('pager', 'quiet'): | 63 if ui.configbool('pager', 'quiet'): |
61 signal.signal(signal.SIGPIPE, signal.SIG_DFL) | 64 signal.signal(signal.SIGPIPE, signal.SIG_DFL) |
62 return orig(ui, options, cmd, cmdfunc) | 65 return orig(ui, options, cmd, cmdfunc) |
63 | 66 |
64 extensions.wrapfunction(dispatch, '_runcommand', pagecmd) | 67 extensions.wrapfunction(dispatch, '_runcommand', pagecmd) |
68 | |
69 attended = ['annotate', 'cat', 'diff', 'export', 'glog', 'log', 'qdiff'] |