[PATCH] convert/svn: Abort operation when python bindings are not available

Mads Kiilerich mads at kiilerich.com
Sat Feb 19 19:31:04 CST 2011


Azhagu Selvan SP wrote, On 02/19/2011 05:49 AM:
> On Fri, 2011-02-18 at 20:48 +0100, Mads Kiilerich wrote:
>
>> Thanks for the patch, but I'm afraid this approach won't work.
>>
>> The import has to fail silently here, and the missing libraries should
>> be caught later in the svn_source constructor where it tries to access
>> SubversionException.
> Ah sorry! I didn't notice this code.
>
>> I guess it is your experience that it doesn't happen that way? What do
>> you see - and can you figure out exactly why it doesn't work as intended?
>>
>> /Mads
>
> Yes. Actually the import transport statement is inside the top level try
> block. So when the svn import fails, the 'import transport' never
> executes and it raises exception at line no.1009., Where it tries to
> access the transport module.

Oh ...

>   May be moving the 'import transport' line
> out of the try block should do fine?

No. transport.py will unconditionally import svn, so it has to be 
imported in the try/except ... at least in principle ...

(The confusing exception is that demandload usually will delay the 
exception to the first time the imported module is used. We must make 
sure that doesn't cause trouble in either direction. The import from 
svn.core will however not be delayed and it will fail immediately if it 
fails.)

I think the best and most maintainable solution is to set svn to None if 
the imports fails and then make sure that all (2?) relevant entry points 
fails properly "if not svn" (insteaf of accessing SubversionException).

Will you create, test and post another patch with something like that?

/Mads



More information about the Mercurial-devel mailing list