[PATCH stable] hooks: only disable/re-enable demandimport when it's already enabled

Simon Heimberg simohe at besonet.ch
Tue Feb 11 14:33:32 CST 2014



--On 2014-02-11 12:08 -0800 Brodie Rao <brodie at sf.io> wrote:
> On Mon, Feb 10, 2014 at 3:51 PM, Simon Heimberg <Simohe at besonet.ch> wrote:
>> Am 11.02.2014 00:00, schrieb Brodie Rao:
>>
>>> # HG changeset patch
>>> # User Brodie Rao <brodie at sf.io>
>>> # Date 1392072666 28800
>>> #      Mon Feb 10 14:51:06 2014 -0800
>>> # Branch stable
>>> # Node ID aac87f70f38e1561c98057fc845f333b185b6d5d
>>> # Parent  e4d7cbc94219e54f5e73df9c2f88eca3d46d7f90
>>> hooks: only disable/re-enable demandimport when it's already enabled
>>>
>>> diff --git a/mercurial/demandimport.py b/mercurial/demandimport.py
<snip>
>>> -            obj = __import__(modname)
>>
>>
>> Why did we disable demandimport here? __import__ is never delayed. (See
>> comment at start of mercurial/demandimport.py) Let's only remove disable
>> and enable.
>
> I believe that change was made to disable demandimport for import
> statements made inside the extension. Using __import__() here only
> bypasses demandimport when importing the extension itself;
> demandimport will still be enabled for the extension's own imports.
>
> So I don't think removing disable/enable is the right thing to do. I
> think my patch as it stands is OK.
>

Absolutely right. Enabling was introduced in d7c28954d901, the commit 
message tells exactly this. Maybe you should add a comment to prevent me 
from removing it.  (-:
The patch is already pushed to stable, so it looked good for somebody 
responsible, and you convinced me too.

Greetings,
Simon

>>
>>
>>> -            demandimport.enable()
>>> -        except ImportError:
<snip>


More information about the Mercurial-devel mailing list