tools/mercurial/mach_commands.py

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     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/.
     5 from __future__ import print_function, unicode_literals
     7 import os
     8 import sys
    10 from mach.decorators import (
    11     CommandProvider,
    12     Command,
    13 )
    16 @CommandProvider
    17 class VersionControlCommands(object):
    18     def __init__(self, context):
    19         self._context = context
    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__))
    26         from hgsetup.wizard import MercurialSetupWizard
    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))
    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)
    40         return result

mercurial