Skip to content
Snippets Groups Projects
Commit 3eae4bab authored by Gregory Szorc's avatar Gregory Szorc
Browse files

Bug 1384396 - Detect Watchman Mercurial integration in configure; r=nalexander

Configure now detects VCS info. Configure now detects Watchman.
We can combine the two so configure can detect if Mercurial
is configured with Watchman enabled.

This commit does two things:

1) collects the Mercurial config so it is available to downstream checks
2) examines the config for presence and state of the fsmonitor
   extension

We don't yet do anything with the fsmonitor state. But it should be
useful soon. Also, the return value is kinda wonky. This will almost
certainly be improved as soon as there is an actual consumer.

MozReview-Commit-ID: HyHZ2X8VI0h

--HG--
extra : rebase_source : e53928127470340275f0c0f07db72b536bba885b
extra : source : a8373914cbfd9b8595fc24f36c876cab0a26c02a
parent df019d6a
No related branches found
No related tags found
No related merge requests found
......@@ -353,6 +353,39 @@ def hg_version(hg):
return Version(match.group(1))
# Resolve Mercurial config items so other checks have easy access.
# Do NOT set this in the config because it may contain sensitive data
# like API keys.
@depends_all(check_build_environment, hg, hg_version)
@imports('os')
def hg_config(build_env, hg, version):
env = dict(os.environ)
env['HGPLAIN'] = '1'
# Warnings may get sent to stderr. But check_cmd_output() ignores
# stderr if exit code is 0. And the command should always succeed if
# `hg version` worked.
out = check_cmd_output(hg, 'config', env=env, cwd=build_env.topsrcdir)
# out is bytes. However, unicode literals are in effect, so implicit
# type coercion can occur. The underlying Mercurial config file may be
# in a user-defined encoding. However, HGPLAIN both overrides the decoding
# inside Mercurial *and* ensures output is utf-8. Because moz.configure
# is using unicode literals, our returned config object uses unicode
# keys and values to limit potential for coercion.
# Mercurial should emit utf-8. But be paranoid and ignore invalid utf-8
# byte sequences.
out = out.decode('utf-8', 'replace')
config = {}
for line in out.strip().splitlines():
key, value = [s.strip() for s in line.split('=', 1)]
config[key] = value
return config
@depends_if(git)
@checking('for Git version')
@imports('re')
......
......@@ -378,6 +378,29 @@ def watchman_version(watchman):
res = json.loads(out)
return Version(res['version'])
@depends_all(hg_version, hg_config, watchman)
@checking('for watchman Mercurial integration')
@imports('os')
def watchman_hg(hg_version, hg_config, watchman):
if hg_version < Version('3.8'):
return 'no (Mercurial 3.8+ required)'
ext_enabled = False
mode_disabled = False
for k in ('extensions.fsmonitor', 'extensions.hgext.fsmonitor'):
if k in hg_config and hg_config[k] != '!':
ext_enabled = True
mode_disabled = hg_config.get('fsmonitor.mode') == 'off'
if not ext_enabled:
return 'no (fsmonitor extension not enabled)'
if mode_disabled:
return 'no (fsmonitor.mode=off disables fsmonitor)'
return True
# Miscellaneous programs
# ==============================================================
check_prog('DOXYGEN', ('doxygen',), allow_missing=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment