Commit Graph

51 Commits

Author SHA1 Message Date
Gregory Szorc
b1321c4998 pager: ensure wrapped dispatch._runcommand runs before color's
An upcoming patch will teach color to potentially act differently if the
pager is active. Since both extensions wrap the same function
(dispatch._runcommand) to change behavior, we must guarantee that
pager's wrapped function runs before color's so color may read the
breadcrumb left by pager.
2015-02-06 12:09:09 -08:00
Gregory Szorc
df5acb8a96 pager: set an attribute on ui indicating that a pager is active
A subsequent patch will teach the color extension to do different things
depending on whether a pager is active. This patch leaves a breadcrumb
on the ui instance to allow it do that that.
2015-02-06 12:07:56 -08:00
Matt Mackall
8f271ab8db pager: add attend-<command> option
This lets users override attend settings locally on a command
granularity.
2014-05-09 13:32:56 -05:00
Matt Mackall
9f887e4452 pager: variable reorder 2014-05-09 13:10:23 -05:00
Matt Mackall
5c5576136a pager: break auto out of command check loop 2014-05-09 13:07:50 -05:00
Matt Mackall
e855b86a3a pager: break always out of command check loop 2014-05-09 13:05:52 -05:00
Matt Mackall
911703535d pager: break pager invocation out of command check loop 2014-05-09 12:58:53 -05:00
Mads Kiilerich
2629efac4f config: set a 'source' in most cases where config don't come from file but code
Some extensions set configuration settings that showed up in 'hg showconfig
--debug' with 'none' as source. That was confusing.

Instead, they will now tell which extension they come from.

This change tries to be consistent and specify a source everywhere - also where
it perhaps is less relevant.
2014-03-19 02:45:14 +01:00
David Soria Parra
d4d544f551 pager: honour internal aliases
If paging is configured for a command all it's internal defined aliases
will be paged as well. This will make attend=log cause 'hg history'
to run the pager. However custom aliases will not be paged by default.
2013-10-12 18:51:34 -07:00
Bryan O'Sullivan
4a4e45180d pager: add missing imports of errno and shlex
Found using Cython.
2013-04-12 17:35:56 -07:00
Matt Mackall
fb3c5e53c4 pager: catch ctrl-c on exit (issue3834) 2013-02-22 15:17:33 -06:00
Thomas Arendsen Hein
ef236f0ec1 pager: drop -S option for less in example for pager configuration
Using less -S will hide possibly important information when reviewing a
changeset, e.g. something wrong/dangerous after the 80th column, because
"less" will not give an indication that following characters are hidden.
2012-07-31 15:50:44 +02:00
Michael Bacarella
497a8d346f pager: work around bug in python 2.4's subprocess module (issue3533)
hg v2.2.2 fixed the pager on Windows, but broke it on Python 2.4.
This patch only uses the new behavior if Python >= 2.5 is detected.
2012-07-06 18:06:52 -04:00
Matt Mackall
99486917d1 pager: use ui._isatty infrastructure 2012-05-20 14:33:49 -05:00
Augie Fackler
96d44b39f7 hgext: mark all first-party extensions as such 2012-05-15 14:37:49 -05:00
David Soria Parra
7bbe0ff197 pager: check if signal.SIGPIPE exists
We have to check for signal.SIGPIPE before we attempt
to set it.
2012-05-12 09:43:12 +02:00
David Soria Parra
d6e40e51fb pager: remove quiet flag
With the pager running as a child process, exiting the pager doesn't
result in a broken pipe message. To distinguish the exit broken pipe code
from a mercurial abort we register the default action for SIGPIPE. This
results in a 141 exit code instead of a 255. On windows SIGPIPE doesn't
exists and a ValueError will be thrown.
2012-05-11 16:08:49 +02:00
Brodie Rao
6fdaf7d897 pager: preserve Hg's exit code (and fix Windows support) (issue3225)
This changes how the pager extension invokes the pager. Prior to this change,
the extension would fork Hg and exec the pager in the parent process. This
loses Hg exit code, and it doesn't work on Windows.

Now the pager is invoked using the subprocess library, and an atexit handler is
registered that makes Hg wait for the pager to exit before it exits itself.

Note that if you exit the pager before Hg is done running, you'll get an exit
code of 255, which is caused by Python blowing up due to a broken pipe. If you
set pager.quiet=True, you'll get the OS-level return code of 141.
2012-05-11 15:45:37 +02:00
Augie Fackler
3fddb45056 hgext: replace uses of hasattr with util.safehasattr 2011-07-25 20:37:12 -05:00
Idan Kamara
02f21a70dc util: add helper function isatty(fd) to check for tty-ness 2011-06-02 00:43:34 +03:00
Brodie Rao
2fb8bf1f24 pager: don't page stderr if it's being redirected (issue2541) 2011-01-04 00:24:34 +11:00
Kevin Bullock
deaad9124d pager: make example of setting pager less silly 2010-10-29 00:57:34 -05:00
Martin Geisler
94a99c16c9 pager: backout 211c3a983bd3 (issue2441) 2010-10-29 14:47:45 +02:00
Brodie Rao
64fa99143f pager: don't run pager if nothing is written to stdout/stderr
This decides when to run the pager based on the first call to
ui.write() and ui.write_err(). This has the side effect of not the
output of subprocesses that write output before hg does.
2010-10-10 12:21:49 -05:00
Brodie Rao
6b1702dd44 pager: add global --pager=<auto/boolean> option 2010-10-10 12:21:48 -05:00
Brodie Rao
5a1e1994ac help: refer to user configuration file more consistently
Currently, a number of commands and help topics mention the user hgrc
file in different ways. Among these are following:

1. .hgrc - "please specify your commit editor/username in your .hgrc
file", bookmarks, color, hgk, pager, hg help environment

2. $HOME/.hgrc - hg help paths, hgrc(5), hg(1)

3. ~/.hgrc - hgrc(5)

In addition to being inconsistent, none of these make sense on
Windows. This patch replaces the above with a more general term of
"[your] configuration file".
2010-08-27 22:36:35 -04:00
Yuya Nishihara
968bdb2fd0 pager: respect HGPLAIN
Pager shouldn't be enabled for scripting use.
2010-06-20 01:20:12 +09:00
Dan Villiom Podlaski Christiansen
e64c6d6314 pager: set ui.formatted() prior to redirecting stdout. 2010-06-07 15:34:48 +02:00
Brodie Rao
97e764bcba pager: exec pager using /bin/sh -c
This mimics the behavior of popen() and ensures setting the pager to something
like "LESS=FSRX less" will work.
2010-05-19 09:54:12 -05:00
Matt Mackall
0eed4acf96 Merge with stable 2010-05-16 14:38:32 -05:00
Brodie Rao
6239bef137 pager: fork and exec pager as parent process
With the pager as the child process instead of the parent process, the
termination of the parent Mercurial process can cause the terminal to return
before the pager exits. Inverting the relationship prevents that issue.

Platforms without fork() will continue to use util.popen().
2010-05-03 14:00:34 -05:00
Martin Geisler
f1853c5e82 Use hg role in help strings 2010-04-22 10:24:49 +02:00
Brodie Rao
0f2039e2cc pager: set ui.interactive=False when enabled
This stops interactive-only things like progress bars from showing up
inside the pager.
2010-02-19 22:16:42 -05:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Martin Geisler
70de345b15 hgext: enable extensions without "hgext." prefix in help texts 2009-12-22 00:50:03 +01:00
Brodie Rao
4f62e5a654 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.)
2009-11-12 10:29:40 -05:00
Martin Geisler
5cca165d9b pager: wrap docstrings at 70 characters 2009-07-26 01:56:02 +02:00
Martin Geisler
cf2fd9726e pager: use reST syntax for literal blocks 2009-07-23 00:24:03 +02:00
Martin Geisler
42ae308e52 pager: wrapped docstrings at 78 characters 2009-07-07 23:54:42 +02:00
Cédric Duval
dbcec5595d extensions: improve the consistency of synopses
Trying as much as possible to consistently:
 - use a present tense predicate followed by a direct object
 - verb referring directly to the functionality provided
   (ie. not "add command that does this" but simple "do that")
 - keep simple and to the point, leaving details for the long help
   (width is tight, possibly even more so for translations)

Thanks to timeless, Martin Geisler, Rafael Villar Burke, Dan Villiom
Podlaski Christiansen and others for the helpful suggestions.
2009-06-22 15:48:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Martin Geisler
1978b6086c pager: word-wrap help texts at 70 characters 2009-04-04 23:18:13 +02:00
Matt Mackall
e564d351f3 extensions: use new wrapper functions 2008-10-22 17:34:52 -05:00
Dirkjan Ochtman
2f149e4634 replace usage of os.popen() with util.popen()
To make this possible, I added a mode parameter to both implementations of
util.popen(), defaulting to 'r' (as it does in the Python stdlib).
2008-04-14 14:34:38 +02:00
Christian Ebert
87c730b788 pager: make config info accessible with "hg help pager" 2008-04-03 13:47:05 +02:00
Dirkjan Ochtman
c31920c8cc Merge from crew-stable. 2008-04-03 11:16:07 +02:00
Gilles Moris
5b548b29f2 Pager extension: switch it off if --debugger is set
The pager is preventing the debugger prompt and much of the
debugger output to be refreshed. Moreover the pager does not
make sense when debugging line by line.

(This supersedes the similar ui.debugflag patch. Disabling
the pager for debug output doesn't make that much sense,
as this is actually when the pager might be useful.)
2008-04-03 11:11:31 +02:00
David Soria Parra ext:(%20php.net%3E)
daf7ac79da Pager extension: switch it off if --debugger is set
The pager is preventing the debugger prompt and much of the
debugger output to be refreshed. Moreover the pager does not
make sense when debugging line by line (Thanks to Gilles Moris).
2008-04-03 10:49:42 +02:00
David Soria Parra ext:(%20php.net%3E)
b9cec105a4 pager: Add a configuration to enable/disable the pager for certain commands
Add the configuration options pager.ignore and pager.attend.
You can disable the pager on certain commands by adding them to the
pager.ignore setting. To whitelist commands, you can add them to pager.attend.
To disable or enable global commands like 'hg version' or 'hg help'
you have to use your global .hgrc. (thanks, Matt Mackall)
2008-03-29 19:41:50 +01:00
Matt Mackall
a0ccc8000c pager: further simplify code, clean up comments 2008-03-20 11:12:35 -05:00