Bug 1231989 - Prompt to install hgwatchman extension; r=ahal

This can speed up performance significantly.

Only support OS X for now because on Linux we have to adjust inode
limits to support mozilla-central and I don't feel like scope bloating.
This commit is contained in:
Gregory Szorc 2015-12-11 13:02:53 -05:00
parent 282adea850
commit 24ce46566b
2 changed files with 45 additions and 0 deletions

View File

@ -23,6 +23,7 @@ class MercurialUpdater(object):
def __init__(self, state_dir):
self.state_dir = os.path.normpath(state_dir)
self.vcs_tools_dir = os.path.join(self.state_dir, 'version-control-tools')
self.hgwatchman_dir = os.path.join(self.state_dir, 'hgwatchman')
def update_all(self):
hg = get_hg_path()
@ -34,6 +35,12 @@ class MercurialUpdater(object):
self.vcs_tools_dir,
'default',
'Ensuring version-control-tools is up to date...')
self.update_mercurial_repo(
hg,
'https://bitbucket.org/facebook/hgwatchman',
self.hgwatchman_dir,
'default',
'Ensuring hgwatchman is up to date...')
if repo_existed:
print(FINISHED)
return 0

View File

@ -258,6 +258,22 @@ is in.)
Would you like to install the `hg wip` alias?
'''.strip()
HGWATCHMAN_MINIMUM_VERSION = LooseVersion('3.5.2')
HGWATCHMAN_INFO = '''
The hgwatchman extension integrates the watchman filesystem watching
tool with Mercurial. Commands like `hg status`, `hg diff`, and
`hg commit` that need to examine filesystem state can query watchman
and obtain filesystem state nearly instantaneously. The result is much
faster command execution.
When installed, the hgwatchman extension will launch a background
watchman file watching daemon for accessed Mercurial repositories. It
should "just work."
Would you like to install hgwatchman
'''.strip()
FILE_PERMISSIONS_WARNING = '''
Your hgrc file is currently readable by others.
@ -372,6 +388,28 @@ class MercurialSetupWizard(object):
'rewriting via the "histedit" command (similar to '
'`git rebase -i`)')
# hgwatchman is provided by MozillaBuild and we don't yet support
# Linux/BSD.
if ('hgwatchman' not in c.extensions
and sys.platform.startswith('darwin')
and hg_version >= HGWATCHMAN_MINIMUM_VERSION
and self._prompt_yn(HGWATCHMAN_INFO)):
# Unlike other extensions, we need to run an installer
# to compile a Python C extension.
try:
subprocess.check_output(
['make', 'local'],
cwd=self.updater.hgwatchman_dir,
stderr=subprocess.STDOUT)
ext_path = os.path.join(self.updater.hgwatchman_dir,
'hgwatchman')
if self.can_use_extension(c, 'hgwatchman', ext_path):
c.activate_extension('hgwatchman', ext_path)
except subprocess.CalledProcessError as e:
print('Error compiling hgwatchman; will not install hgwatchman')
print(e.output)
self.prompt_native_extension(c, 'mq', MQ_INFO)
if 'reviewboard' not in c.extensions: