comparison mercurial/utils/procutil.py @ 40712:246b61bfdc2f

procutil: don't allow the main 'hg' script to be treated as the Windows exe Previously, there were a handful of errors like this: $ hg prefetch --repack (running background incremental repack) + abort: %1 is not a valid Win32 application + [255] CreateProcess() doesn't append .exe when `lpApplicationName` contains a path, and a python script isn't directly executable.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 23 Nov 2018 22:27:57 -0500
parents 1d3bed7d2923
children 8ecb17b7f432
comparison
equal deleted inserted replaced
40711:72d88a975655 40712:246b61bfdc2f
239 if getattr(sys, 'frozen', None) == 'macosx_app': 239 if getattr(sys, 'frozen', None) == 'macosx_app':
240 # Env variable set by py2app 240 # Env variable set by py2app
241 _sethgexecutable(encoding.environ['EXECUTABLEPATH']) 241 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
242 else: 242 else:
243 _sethgexecutable(pycompat.sysexecutable) 243 _sethgexecutable(pycompat.sysexecutable)
244 elif (os.path.basename( 244 elif (not pycompat.iswindows and os.path.basename(
245 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'): 245 pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
246 _sethgexecutable(pycompat.fsencode(mainmod.__file__)) 246 _sethgexecutable(pycompat.fsencode(mainmod.__file__))
247 else: 247 else:
248 exe = findexe('hg') or os.path.basename(sys.argv[0]) 248 exe = findexe('hg') or os.path.basename(sys.argv[0])
249 _sethgexecutable(exe) 249 _sethgexecutable(exe)