[PATCH 3 of 3] util: adjust hgcmd() to handle frozen Mercurial on OS X

Matt Harbison matt_harbison at yahoo.com
Mon Jan 11 11:32:08 CST 2016


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1452467739 18000
#      Sun Jan 10 18:15:39 2016 -0500
# Node ID d279695282ab51520cece490782e60833d1cdcff
# Parent  82944be0a4a6158bc9b2e0ce04fd108eea078805
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.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -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):


More information about the Mercurial-devel mailing list