[PATCH] Minimal fix for non-py2exe config search path

Stephen Darnell stephen at darnell.plus.com
Mon May 15 11:00:19 CDT 2006


Thomas wrote:
>> This patch prevents looking in the python directory for configuration files.
>> I don't have py2exe installed but it seems that sys.frozen should be present
>> in that case.
>> ...patch...
>
>Would be better to always look in both locations so the user is less
>surprised?

It feels wrong to me to look for a mercurial.ini in the python directory - even though it probably does no harm.
But presumably your question is why not look in c:\mercurial\mercurial.ini always anyway?

I could certainly do this but it feels a bit naff (an arbitrary directory etc.), and not looking there if you can avoid it seems slightly less naff - but it does leave a sprinkle of inconsistency.

I slighly better alternative I mentioned was to use the directory where mercurial .py files are installed which can be retrieved portably/reliably and for me would be C:\Python24\Lib\site-packages\mercurial.  This allows multiple installations of mercurial if 
necessary, no hard coded paths, and would be viable for other platforms too.  But I don't know if this is common python practice?

>And why doesn't something like
>os.path.join(os.path.dirname(sys.argv[0]), 'mercurial.ini')
>work on windows?

That would be far too easy :)  No seriously, Windows does not always put the full pathname in argv[0].

Another issue might be if mercurial is invoked in python from other tools, as has been discussed in the mailing list recently - although that is probably not such a bad thing.

For windows, the canonical storage place for system wide configuration is the registry (although this is changing a little with .Net), and I imagine many Windows users might expect to find Mercurial settings under
 HKLM/SOFTWARE/Mercurial or HKLM/SOFTWARE/Python/Mercurial
but as the current code/parser reads files that's a little bit of fiddling around, and seems to rely on the win32 extensions.

Please let me know what your preference is - or alter the patch and submit something similar.

Regards,
  Stephen


More information about the Mercurial mailing list