Bug 1128586 - Prefer hg.exe over hg; r=RyanVM

This is needed for compatibility with an upcoming release of
MozillaBuild, which distributes Mercurial as a Python package, not as a
standalone Windows program. As a result, it introduces "hg" into $PATH,
which "which" will happily prefer as the "hg" binary. This upsets
subprocess. So, we explicitly prefer "hg.exe" over "hg".

We could accomplish the same thing by calling which.whichall() and
sorting results. But this is more code and IMO not worth the effort to
implement.

--HG--
extra : rebase_source : 750ba02c02fd4a9fab42ccf128eab4f5e7741564
extra : amend_source : 8fb84c0ed5cd14dd27ad6cd7b78fb2ac1ffc87a2
This commit is contained in:
Gregory Szorc 2015-04-27 10:43:49 -07:00
Родитель 243db8e774
Коммит 744bbc11a4
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -178,13 +178,21 @@ class MercurialSetupWizard(object):
if e.errno != errno.EEXIST:
raise
# We use subprocess in places, which expects a Win32 executable or
# batch script. On some versions of MozillaBuild, we have "hg.exe",
# "hg.bat," and "hg" (a Python script). "which" will happily return the
# Python script, which will cause subprocess to choke. Explicitly favor
# the Windows version over the plain script.
try:
hg = which.which('hg')
except which.WhichError as e:
print(e)
print('Try running |mach bootstrap| to ensure your environment is '
'up to date.')
return 1
hg = which.which('hg.exe')
except which.WhichError:
try:
hg = which.which('hg')
except which.WhichError as e:
print(e)
print('Try running |mach bootstrap| to ensure your environment is '
'up to date.')
return 1
try:
c = MercurialConfig(config_paths)