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

Jason Harris jason at jasonfharris.com
Mon Apr 18 06:20:55 CDT 2011


On Apr 18, 2011, at 3:19 AM, Augie Fackler wrote:

> On Apr 17, 2011, at 7:43 PM, Jason Harris wrote:
>> 
>> # 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
> 
> Should probably be something like:
> util.termwidth: never return 0 for terminal width
> 
> since this isn't progress-specific.

You are right. I will change this... (I discovered this through the progress extension
and it was stopping progress from working...)


>> 
>> 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:
>> +                    return width
>>           except ValueError:
>>               pass
>>           except IOError, e:
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
> 
> 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list