Bug 1277406 - Move mach mercurial-setup implementation into bootstrap; r=glandium

This begins the consolidation of `mach mercurial-setup` into
`mach bootstrap`. The first step is to move the content of the
mach_commands.py file into the bootstrapper's.

I'm not crazy about adding the sys.path entry for tools/mercurial.
I intend to clean this up later.

MozReview-Commit-ID: Cq56wPG8sO1

--HG--
extra : rebase_source : 48d6d2631760c9333bf99285673430948085630e
extra : histedit_source : e062f6fbc0ae9678347801b4a1f1c9b6912afd52
This commit is contained in:
Gregory Szorc 2016-06-01 17:06:01 -07:00
parent 0da1045b72
commit 517e7b2b60
3 changed files with 50 additions and 62 deletions

View File

@ -90,6 +90,7 @@ SEARCH_PATHS = [
'testing/web-platform/harness',
'testing/web-platform/tests/tools/wptserve',
'testing/xpcshell',
'tools/mercurial',
'xpcom/idl-parser',
]
@ -122,7 +123,6 @@ MACH_MODULES = [
'testing/xpcshell/mach_commands.py',
'tools/docs/mach_commands.py',
'tools/lint/mach_commands.py',
'tools/mercurial/mach_commands.py',
'tools/mach_commands.py',
'tools/power/mach_commands.py',
'mobile/android/mach_commands.py',

View File

@ -2,9 +2,13 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this,
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from mach.decorators import (
CommandArgument,
CommandProvider,
Command,
)
@ -21,3 +25,47 @@ class Bootstrap(object):
bootstrapper = Bootstrapper()
bootstrapper.bootstrap()
@CommandProvider
class VersionControlCommands(object):
def __init__(self, context):
self._context = context
@Command('mercurial-setup', category='devenv',
description='Help configure Mercurial for optimal development.')
@CommandArgument('-u', '--update-only', action='store_true',
help='Only update recommended extensions, don\'t run the wizard.')
def mercurial_setup(self, update_only=False):
"""Ensure Mercurial is optimally configured.
This command will inspect your Mercurial configuration and
guide you through an interactive wizard helping you configure
Mercurial for optimal use on Mozilla projects.
User choice is respected: no changes are made without explicit
confirmation from you.
If "--update-only" is used, the interactive wizard is disabled
and this command only ensures that remote repositories providing
Mercurial extensions are up to date.
"""
config_paths = ['~/.hgrc']
if sys.platform in ('win32', 'cygwin'):
config_paths.insert(0, '~/mercurial.ini')
config_paths = map(os.path.expanduser, config_paths)
if update_only:
from hgsetup.update import MercurialUpdater
updater = MercurialUpdater(self._context.state_dir)
result = updater.update_all()
else:
from hgsetup.wizard import MercurialSetupWizard
wizard = MercurialSetupWizard(self._context.state_dir)
result = wizard.run(map(os.path.expanduser, config_paths))
if result:
print('(despite the failure, mach will not nag you to run '
'`mach mercurial-setup`)')
return result

View File

@ -1,60 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this,
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
import os
import sys
from mach.decorators import (
CommandProvider,
CommandArgument,
Command,
)
@CommandProvider
class VersionControlCommands(object):
def __init__(self, context):
self._context = context
@Command('mercurial-setup', category='devenv',
description='Help configure Mercurial for optimal development.')
@CommandArgument('-u', '--update-only', action='store_true',
help='Only update recommended extensions, don\'t run the wizard.')
def mercurial_setup(self, update_only=False):
"""Ensure Mercurial is optimally configured.
This command will inspect your Mercurial configuration and
guide you through an interactive wizard helping you configure
Mercurial for optimal use on Mozilla projects.
User choice is respected: no changes are made without explicit
confirmation from you.
If "--update-only" is used, the interactive wizard is disabled
and this command only ensures that remote repositories providing
Mercurial extensions are up to date.
"""
sys.path.append(os.path.dirname(__file__))
config_paths = ['~/.hgrc']
if sys.platform in ('win32', 'cygwin'):
config_paths.insert(0, '~/mercurial.ini')
config_paths = map(os.path.expanduser, config_paths)
if update_only:
from hgsetup.update import MercurialUpdater
updater = MercurialUpdater(self._context.state_dir)
result = updater.update_all()
else:
from hgsetup.wizard import MercurialSetupWizard
wizard = MercurialSetupWizard(self._context.state_dir)
result = wizard.run(map(os.path.expanduser, config_paths))
if result:
print('(despite the failure, mach will not nag you to run '
'`mach mercurial-setup`)')
return result