[PATCH] progress: fix term width on OSX when called from external scripts

Christian Ebert blacktrash at gmx.net
Mon Apr 18 06:07:29 CDT 2011


* Jason Harris on Monday, April 18, 2011 at 02:43:24 +0200
> # HG changeset patch
> # User jfh <jason at jasonfharris.com>
> # Date 1303087372 -7200
> # Node ID 48f17a64fe93326dcfb9eba307f98b6730e192ba
> # Parent  3637c5384a73e35bbbecc611004351a75d8d6b8f
> progress: fix term width on OSX when called from external scripts
> 
> Catch a case where the termwidth was being reported as 0 when I was connecting
> with TLMTask instead of NSTask in OSX. This caused the progress extension to
> print no progress. The termwidth should never return 0 so in case we would
> return 0, simply fall back to the default termwidth below which is 80.
> 
> diff --git a/mercurial/posix.py b/mercurial/posix.py
> --- a/mercurial/posix.py
> +++ b/mercurial/posix.py
> @@ -340,7 +340,9 @@
>                 if not os.isatty(fd):
>                     continue
>                 arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
> -                return array.array('h', arri)[1]
> +                width = array.array('h', arri)[1]
> +                if width != 0:

Why not just:
                   if width:
?
     
> +                    return width
>             except ValueError:
>                 pass
>             except IOError, e:
-- 
theatre - books - texts - movies
Black Trash Productions at home: http://www.blacktrash.org
Black Trash Productions on Facebook:
http://www.facebook.com/blacktrashproductions


More information about the Mercurial-devel mailing list