util: adjust hgcmd() to handle frozen Mercurial on OS X
Previously, 'hg serve -d' was trying to exec the bundled python executable,
which failed with:
Unknown option: --
usage: python [option] ...
Try 'python -h'...
abort: child process failed to start
See the previous patch for details about the content of the various command
variables. Note that unlike the previous patch here an application bundling
Mercurial could set $HG in the environment to get the correct result, there
isn't anything that a bundling application could do to get the correct result
here.
'hg serve -d' now launches under TortoiseHg, and there is a process listed in
the background, but a client process cannot connect to it for some reason, so
more investigation is needed.
--- a/mercurial/util.py Sun Jan 10 17:56:08 2016 -0500
+++ b/mercurial/util.py Sun Jan 10 18:15:39 2016 -0500
@@ -2044,7 +2044,11 @@
get either the python call or current executable.
"""
if mainfrozen():
- return [sys.executable]
+ if getattr(sys, 'frozen', None) == 'macosx_app':
+ # Env variable set by py2app
+ return [os.environ['EXECUTABLEPATH']]
+ else:
+ return [sys.executable]
return gethgcmd()
def rundetached(args, condfn):