[PATCH] pager: check for stdout.isatty in a try block
Matt Mackall
mpm at selenic.com
Wed Jun 1 17:47:55 CDT 2011
On Thu, 2011-06-02 at 00:56 +0300, Idan Kamara wrote:
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1306964614 -10800
> # Node ID 0ded137fb830436f8668f9745041b3ab6d9d4be9
> # Parent eccbb9980ada13088722a3ab88117cb8c8c8c37e
> pager: check for stdout.isatty in a try block
>
> stdout may not have a isatty attribute.
>
> also, move some checks to uisetup() to save
> needless wrapping.
Seems like we've been bitten by this stupid isatty thing several times
now. We should have a util.isatty(filelike) to take care of it.
> diff -r eccbb9980ada -r 0ded137fb830 hgext/pager.py
> --- a/hgext/pager.py Thu Jun 02 00:43:34 2011 +0300
> +++ b/hgext/pager.py Thu Jun 02 00:43:34 2011 +0300
> @@ -86,12 +86,19 @@
> raise
>
> def uisetup(ui):
> - if ui.plain():
> + def isatty():
> + try:
> + return sys.stdout.isatty()
> + except AttributeError:
> + return False
> +
> + if ui.plain() or '--debugger' in sys.argv or not isatty():
> return
>
> def pagecmd(orig, ui, options, cmd, cmdfunc):
> p = ui.config("pager", "pager", os.environ.get("PAGER"))
> - if p and sys.stdout.isatty() and '--debugger' not in sys.argv:
> +
> + if p:
> attend = ui.configlist('pager', 'attend', attended)
> auto = options['pager'] == 'auto'
> always = util.parsebool(options['pager'])
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list