1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tools/mercurial/mach_commands.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this, 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +from __future__ import print_function, unicode_literals 1.9 + 1.10 +import os 1.11 +import sys 1.12 + 1.13 +from mach.decorators import ( 1.14 + CommandProvider, 1.15 + Command, 1.16 +) 1.17 + 1.18 + 1.19 +@CommandProvider 1.20 +class VersionControlCommands(object): 1.21 + def __init__(self, context): 1.22 + self._context = context 1.23 + 1.24 + @Command('mercurial-setup', category='devenv', 1.25 + description='Help configure Mercurial for optimal development.') 1.26 + def mercurial_bootstrap(self): 1.27 + sys.path.append(os.path.dirname(__file__)) 1.28 + 1.29 + from hgsetup.wizard import MercurialSetupWizard 1.30 + 1.31 + wizard = MercurialSetupWizard(self._context.state_dir) 1.32 + config_paths = ['~/.hgrc'] 1.33 + if sys.platform in ('win32', 'cygwin'): 1.34 + config_paths.insert(0, '~/mercurial.ini') 1.35 + result = wizard.run(map(os.path.expanduser, config_paths)) 1.36 + 1.37 + # Touch a file so we can periodically prompt to update extensions. 1.38 + state_path = os.path.join(self._context.state_dir, 1.39 + 'mercurial/setup.lastcheck') 1.40 + with open(state_path, 'a'): 1.41 + os.utime(state_path, None) 1.42 + 1.43 + return result