py3: use pycompat.sysargv[0] for instead of fsencode(sys.argv[0])
Yuya noted in a recent review that fsencode(sys.argv[0]) could be
incorrect on Windows.
Differential Revision: https://phab.mercurial-scm.org/D6782
--- a/mercurial/utils/procutil.py Wed Sep 04 14:35:39 2019 -0700
+++ b/mercurial/utils/procutil.py Sun Sep 01 23:43:59 2019 -0700
@@ -245,8 +245,11 @@
pycompat.fsencode(getattr(mainmod, '__file__', ''))) == 'hg'):
_sethgexecutable(pycompat.fsencode(mainmod.__file__))
else:
- exe = findexe('hg') or os.path.basename(sys.argv[0])
- _sethgexecutable(pycompat.fsencode(exe))
+ exe = findexe('hg')
+ if exe:
+ _sethgexecutable(pycompat.fsencode(exe))
+ else:
+ _sethgexecutable(os.path.basename(pycompat.sysargv[0]))
return _hgexecutable
def _sethgexecutable(path):