|
1 # This Source Code Form is subject to the terms of the Mozilla Public |
|
2 # License, v. 2.0. If a copy of the MPL was not distributed with this, |
|
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 from __future__ import print_function, unicode_literals |
|
6 |
|
7 import os |
|
8 import sys |
|
9 |
|
10 from mach.decorators import ( |
|
11 CommandProvider, |
|
12 Command, |
|
13 ) |
|
14 |
|
15 |
|
16 @CommandProvider |
|
17 class VersionControlCommands(object): |
|
18 def __init__(self, context): |
|
19 self._context = context |
|
20 |
|
21 @Command('mercurial-setup', category='devenv', |
|
22 description='Help configure Mercurial for optimal development.') |
|
23 def mercurial_bootstrap(self): |
|
24 sys.path.append(os.path.dirname(__file__)) |
|
25 |
|
26 from hgsetup.wizard import MercurialSetupWizard |
|
27 |
|
28 wizard = MercurialSetupWizard(self._context.state_dir) |
|
29 config_paths = ['~/.hgrc'] |
|
30 if sys.platform in ('win32', 'cygwin'): |
|
31 config_paths.insert(0, '~/mercurial.ini') |
|
32 result = wizard.run(map(os.path.expanduser, config_paths)) |
|
33 |
|
34 # Touch a file so we can periodically prompt to update extensions. |
|
35 state_path = os.path.join(self._context.state_dir, |
|
36 'mercurial/setup.lastcheck') |
|
37 with open(state_path, 'a'): |
|
38 os.utime(state_path, None) |
|
39 |
|
40 return result |