[PATCH] hook: fix full path imports on Windows (issue1779)
Roman V. Kiseliov
roman.kiseliov at gmail.com
Fri Aug 7 06:16:33 CDT 2009
Not for discussion anymore, just want to say.
I've builded binary disritution of Mercurial-1.3.1 with Python-2.5.4
(both ActivePython and not) and py2exe-0.6.9 and it works with initial
patch. I don't have VC 2003, so extensions was compiled with gcc
4.4.0: setup.py build -c mingw32 py2exe. I've tried also 'setup.py
--pure py2exe' with success.
I slightly changed setup.py by appending py2exe options
"includes=['mercurial.base85', 'mercurial.bdiff',
'mercurial.diffhelpers', 'mercurial.mpatch', 'mercurial.parsers',
'mercurial.osutil'])," but I'm shure that it's doen't matter here.
Roman
2009/8/7 Simon Heimberg <simohe at besonet.ch>:
> If there is a file with the same name in PYTHONPATH, this is taken
> instead of the one in the given path. Prepending ([].insert(0, el))
> would be saver.
>
> Is this complexity really needed? Roman wrote that his simpler patch
> works on the binary installation on his computer. (That he builds the
> "new" installation by modifying library.zip has nothing to do with
> this.)
>
> Am Freitag, den 07.08.2009, 04:19 +0000 schrieb Steve Borho:
>> # HG changeset patch
>> # User Steve Borho <steve at borho.org>
>> # Date 1249526754 18000
>> # Node ID 655912763155035408371e67eea4aa3157fd7f03
>> # Parent fb66a7d3f28f69e96369b8d69fc6d775837b40e4
>> hook: fix full path imports on Windows (issue1779)
>>
>> Bottom portion fixes full path imports on source installs on Windows.
>> The top portion further fixes full path imports on binary installs.
>>
>> Initial patch by Roman V. Kiseliov
>>
>> diff -r fb66a7d3f28f -r 655912763155 mercurial/hook.py
>> --- a/mercurial/hook.py Wed Aug 05 17:19:37 2009 +0200
>> +++ b/mercurial/hook.py Wed Aug 05 21:45:54 2009 -0500
>> @@ -27,6 +27,13 @@
>> raise util.Abort(_('%s hook is invalid ("%s" not in '
>> 'a module)') % (hname, funcname))
>> modname = funcname[:d]
>> + oldsyspath = sys.path[:]
>> + if hasattr(sys, "frozen"):
>> + # binary installs require sys.path manipulation
>> + path, name = os.path.split(modname)
>> + if path and name:
>> + sys.path.append(path)
>> + modname = name
>> try:
>> obj = __import__(modname)
>> except ImportError:
>> @@ -37,6 +44,7 @@
>> raise util.Abort(_('%s hook is invalid '
>> '(import of "%s" failed)') %
>> (hname, modname))
>> + sys.path = oldsyspath
>> try:
>> for p in funcname.split('.')[1:]:
>> obj = getattr(obj, p)
>> @@ -110,9 +118,9 @@
>> if hasattr(cmd, '__call__'):
>> r = _pythonhook(ui, repo, name, hname, cmd, args, throw) or r
>> elif cmd.startswith('python:'):
>> - if cmd.count(':') == 2:
>> - path, cmd = cmd[7:].split(':')
>> - mod = extensions.loadpath(path, 'hgkook.%s' % hname)
>> + if cmd.count(':') >= 2:
>> + path, cmd = cmd[7:].rsplit(':', 1)
>> + mod = extensions.loadpath(path, 'hghook.%s' % hname)
>> hookfn = getattr(mod, cmd)
>> else:
>> hookfn = cmd[7:].strip()
>
More information about the Mercurial-devel
mailing list