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
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -85,16 +85,17 @@ SEARCH_PATHS = [
'testing/mozbase/manifestparser',
'testing/puppeteer/firefox',
'testing/taskcluster',
'testing/tools/autotry',
'testing/web-platform',
'testing/web-platform/harness',
'testing/web-platform/tests/tools/wptserve',
'testing/xpcshell',
+ 'tools/mercurial',
'xpcom/idl-parser',
]
# Individual files providing mach commands.
MACH_MODULES = [
'addon-sdk/mach_commands.py',
'build/valgrind/mach_commands.py',
'dom/bindings/mach_commands.py',
@@ -117,17 +118,16 @@ MACH_MODULES = [
'testing/marionette/mach_commands.py',
'testing/mochitest/mach_commands.py',
'testing/mozharness/mach_commands.py',
'testing/talos/mach_commands.py',
'testing/web-platform/mach_commands.py',
'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',
]
CATEGORIES = {
'build': {
--- a/python/mozboot/mozboot/mach_commands.py
+++ b/python/mozboot/mozboot/mach_commands.py
@@ -1,23 +1,71 @@
# 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, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
+
+import os
+import sys
from mach.decorators import (
+ CommandArgument,
CommandProvider,
Command,
)
@CommandProvider
class Bootstrap(object):
"""Bootstrap system and mach for optimal development experience."""
@Command('bootstrap', category='devenv',
description='Install required system packages for building.')
def bootstrap(self):
from mozboot.bootstrap import Bootstrapper
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
deleted file mode 100644
--- a/tools/mercurial/mach_commands.py
+++ /dev/null
@@ -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