[PATCH] dispatch: propagate ui command options to the local ui (issue2523)

Idan Kamara idankk86 at gmail.com
Tue Jun 14 12:22:49 CDT 2011


On Tue, Jun 14, 2011 at 8:14 PM, Georg Brandl <g.brandl at gmx.net> wrote:
> On 12.06.2011 23:38, Idan Kamara wrote:
>> # HG changeset patch
>> # User Idan Kamara <idankk86 at gmail.com>
>> # Date 1307913566 -10800
>> # Node ID 5f743d42591616ba5d1527fd4cdb24cd9e42e4ff
>> # Parent  ab89aec091e5bf82429a08a2953d5614d5b2833f
>> dispatch: propagate ui command options to the local ui (issue2523)
>>
>> so the ui object passed to pre/post python hooks has the verbose flag
>> (and the rest) set correctly
>>
>> diff -r ab89aec091e5 -r 5f743d425916 mercurial/dispatch.py
>> --- a/mercurial/dispatch.py   Sun Jun 12 23:30:39 2011 +0300
>> +++ b/mercurial/dispatch.py   Mon Jun 13 00:19:26 2011 +0300
>> @@ -572,16 +572,20 @@
>>          atexit.register(print_time)
>>
>>      if options['verbose'] or options['debug'] or options['quiet']:
>> -        ui.setconfig('ui', 'verbose', str(bool(options['verbose'])))
>> -        ui.setconfig('ui', 'debug', str(bool(options['debug'])))
>> -        ui.setconfig('ui', 'quiet', str(bool(options['quiet'])))
>> +        for ui in (ui, lui):
>> +            ui.setconfig('ui', 'verbose', str(bool(options['verbose'])))
>> +            ui.setconfig('ui', 'debug', str(bool(options['debug'])))
>> +            ui.setconfig('ui', 'quiet', str(bool(options['quiet'])))
>>      if options['traceback']:
>> -        ui.setconfig('ui', 'traceback', 'on')
>> +        for ui in (ui, lui):
>> +            ui.setconfig('ui', 'traceback', 'on')
>
> This looks fishy: "ui" is rebound in the first for loop that's executed and
> thereafter refers to "lui", so all following for loops will iterate over
> (lui, lui).

Nice catch:

>>> a, b = [], []
>>> print id(a), id(b)
140268181412680 140268181516160
>>> for a in (a, b):
...     print id(a)
...
140268181412680
140268181516160
>>> print id(a), id(b)
140268181516160 140268181516160

Will send a fix in a moment.

>
> Georg
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list