michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this, michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: from __future__ import print_function, unicode_literals michael@0: michael@0: import os michael@0: import sys michael@0: michael@0: from mach.decorators import ( michael@0: CommandProvider, michael@0: Command, michael@0: ) michael@0: michael@0: michael@0: @CommandProvider michael@0: class VersionControlCommands(object): michael@0: def __init__(self, context): michael@0: self._context = context michael@0: michael@0: @Command('mercurial-setup', category='devenv', michael@0: description='Help configure Mercurial for optimal development.') michael@0: def mercurial_bootstrap(self): michael@0: sys.path.append(os.path.dirname(__file__)) michael@0: michael@0: from hgsetup.wizard import MercurialSetupWizard michael@0: michael@0: wizard = MercurialSetupWizard(self._context.state_dir) michael@0: config_paths = ['~/.hgrc'] michael@0: if sys.platform in ('win32', 'cygwin'): michael@0: config_paths.insert(0, '~/mercurial.ini') michael@0: result = wizard.run(map(os.path.expanduser, config_paths)) michael@0: michael@0: # Touch a file so we can periodically prompt to update extensions. michael@0: state_path = os.path.join(self._context.state_dir, michael@0: 'mercurial/setup.lastcheck') michael@0: with open(state_path, 'a'): michael@0: os.utime(state_path, None) michael@0: michael@0: return result