diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py --- a/hgext/inotify/server.py +++ b/hgext/inotify/server.py @@ -461,9 +461,9 @@ def start(ui, dirstate, root, opts): 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 --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -572,7 +572,7 @@ def service(opts, parentfn=None, initfn= 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 --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -262,3 +262,5 @@ def spawndetached(args): return os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), args[0], args) +def gethgcmd(): + return sys.argv[:1] diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1274,3 +1274,14 @@ def iterlines(iterator): 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 --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -352,6 +352,9 @@ def spawndetached(args): STARTUPINFO()) return pid +def gethgcmd(): + return [sys.executable] + sys.argv[:1] + try: # override functions with win32 versions if possible from win32 import *