# HG changeset patch # User Patrick Mezard # Date 1262808718 -3600 # Node ID 8e4be44a676ff64c924949464ad451d48d141061 # Parent e22695b4472fe0af8bab2f9552560b10c2a5e8fc Find right hg command for detached process On Windows, Mercurial can be run from the python script of from a frozen executable. In the first case, we have to call the python interpreter since the script is not executable. Frozen executable can be called directly. Fix 3/3 for issue421 diff -r e22695b4472f -r 8e4be44a676f hgext/inotify/server.py --- a/hgext/inotify/server.py Wed Jan 06 21:11:58 2010 +0100 +++ b/hgext/inotify/server.py Wed Jan 06 21:11:58 2010 +0100 @@ -461,9 +461,9 @@ self.master.shutdown() if 'inserve' not in sys.argv: - runargs = [sys.argv[0], 'inserve', '-R', root] + runargs = util.hgcmd() + ['inserve', '-R', root] else: - runargs = sys.argv[:] + runargs = util.hgcmd() + sys.argv[1:] pidfile = ui.config('inotify', 'pidfile') if opts['daemon'] and pidfile is not None and 'pid-file' not in runargs: diff -r e22695b4472f -r 8e4be44a676f mercurial/cmdutil.py --- a/mercurial/cmdutil.py Wed Jan 06 21:11:58 2010 +0100 +++ b/mercurial/cmdutil.py Wed Jan 06 21:11:58 2010 +0100 @@ -572,7 +572,7 @@ os.close(lockfd) try: if not runargs: - runargs = sys.argv[:] + runargs = util.hgcmd() + sys.argv[1:] runargs.append('--daemon-pipefds=%s' % lockpath) # Don't pass --cwd to the child process, because we've already # changed directory. diff -r e22695b4472f -r 8e4be44a676f mercurial/posix.py --- a/mercurial/posix.py Wed Jan 06 21:11:58 2010 +0100 +++ b/mercurial/posix.py Wed Jan 06 21:11:58 2010 +0100 @@ -262,3 +262,5 @@ return os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), args[0], args) +def gethgcmd(): + return sys.argv[:1] diff -r e22695b4472f -r 8e4be44a676f mercurial/util.py --- a/mercurial/util.py Wed Jan 06 21:11:58 2010 +0100 +++ b/mercurial/util.py Wed Jan 06 21:11:58 2010 +0100 @@ -1274,3 +1274,14 @@ def expandpath(path): return os.path.expanduser(os.path.expandvars(path)) + +def hgcmd(): + """Return the command used to execute current hg + + This is different from hgexecutable() because on Windows we want + to avoid things opening new shell windows like batch files, so we + get either the python call or current executable. + """ + if main_is_frozen(): + return [sys.executable] + return gethgcmd() diff -r e22695b4472f -r 8e4be44a676f mercurial/windows.py --- a/mercurial/windows.py Wed Jan 06 21:11:58 2010 +0100 +++ b/mercurial/windows.py Wed Jan 06 21:11:58 2010 +0100 @@ -352,6 +352,9 @@ STARTUPINFO()) return pid +def gethgcmd(): + return [sys.executable] + sys.argv[:1] + try: # override functions with win32 versions if possible from win32 import *