Bug 1277406 - Remove nagging to run `mach mercurial-setup` from mach; r=glandium draft
authorGregory Szorc <gps@mozilla.com>
Wed, 01 Jun 2016 16:58:01 -0700
changeset 377197 1c1ed9c00eb2164d19e4405f2b8becf59680d1ed
parent 377169 3ccccf8e5036179a3178437cabc154b5e04b333d
child 377198 48d6d2631760c9333bf99285673430948085630e
push id20781
push userbmo:gps@mozilla.com
push dateThu, 09 Jun 2016 23:21:17 +0000
reviewersglandium
bugs1277406
milestone50.0a1
Bug 1277406 - Remove nagging to run `mach mercurial-setup` from mach; r=glandium I never really liked this. Other people had even more visceral reactions. Let's get rid of it. The code for touching a file when it runs has also been removed because the only thing it was used for was the nagging feature. MozReview-Commit-ID: ERUVkEYgkzx
build/mach_bootstrap.py
tools/mercurial/mach_commands.py
--- a/build/mach_bootstrap.py
+++ b/build/mach_bootstrap.py
@@ -26,36 +26,16 @@ filesystem. The following directory will
 If you would like to use a different directory, hit CTRL+c and set the
 MOZBUILD_STATE_PATH environment variable to the directory you would like to
 use and re-run mach. For this change to take effect forever, you'll likely
 want to export this environment variable from your shell's init scripts.
 
 Press ENTER/RETURN to continue or CTRL+c to abort.
 '''.lstrip()
 
-NO_MERCURIAL_SETUP = '''
-*** MERCURIAL NOT CONFIGURED ***
-
-mach has detected that you have never run `{mach} mercurial-setup`.
-
-Running this command will ensure your Mercurial version control tool is up
-to date and optimally configured for a better, more productive experience
-when working on Mozilla projects.
-
-Please run `{mach} mercurial-setup` now.
-
-Note: `{mach} mercurial-setup` does not make any changes without prompting
-you first.
-
-You can disable this check by setting NO_MERCURIAL_SETUP_CHECK=1 in your
-environment.
-'''.strip()
-
-MERCURIAL_SETUP_FATAL_INTERVAL = 31 * 24 * 60 * 60
-
 
 # TODO Bug 794506 Integrate with the in-tree virtualenv configuration.
 SEARCH_PATHS = [
     'python/mach',
     'python/mozboot',
     'python/mozbuild',
     'python/mozlint',
     'python/mozversioncontrol',
@@ -289,53 +269,16 @@ def bootstrap(topsrcdir, mozilla_dir=Non
             return True
 
         # The environment is likely a machine invocation.
         if sys.stdin.closed or not sys.stdin.isatty():
             return True
 
         return False
 
-    def pre_dispatch_handler(context, handler, args):
-        """Perform global checks before command dispatch.
-
-        Currently, our goal is to ensure developers periodically run
-        `mach mercurial-setup` (when applicable) to ensure their Mercurial
-        tools are up to date.
-        """
-        # Don't do anything when...
-        if should_skip_dispatch(context, handler):
-            return
-
-        # User has disabled first run check.
-        if 'I_PREFER_A_SUBOPTIMAL_MERCURIAL_EXPERIENCE' in os.environ:
-            return
-        if 'NO_MERCURIAL_SETUP_CHECK' in os.environ:
-            return
-
-        # Mercurial isn't managing this source checkout.
-        if not os.path.exists(os.path.join(topsrcdir, '.hg')):
-            return
-
-        state_dir = get_state_dir()[0]
-        last_check_path = os.path.join(state_dir, 'mercurial',
-                                       'setup.lastcheck')
-
-        mtime = None
-        try:
-            mtime = os.path.getmtime(last_check_path)
-        except OSError as e:
-            if e.errno != errno.ENOENT:
-                raise
-
-        # No last run file means mercurial-setup has never completed.
-        if mtime is None:
-            print(NO_MERCURIAL_SETUP.format(mach=sys.argv[0]), file=sys.stderr)
-            sys.exit(2)
-
     def post_dispatch_handler(context, handler, args):
         """Perform global operations after command dispatch.
 
 
         For now,  we will use this to handle build system telemetry.
         """
         # Don't do anything when...
         if should_skip_dispatch(context, handler):
@@ -382,19 +325,16 @@ def bootstrap(topsrcdir, mozilla_dir=Non
                     print('\nCreating default state directory: %s' % state_dir)
                     os.makedirs(state_dir, mode=0o770)
 
             return state_dir
 
         if key == 'topdir':
             return topsrcdir
 
-        if key == 'pre_dispatch_handler':
-            return pre_dispatch_handler
-
         if key == 'telemetry_handler':
             return telemetry_handler
 
         if key == 'post_dispatch_handler':
             return post_dispatch_handler
 
         raise AttributeError(key)
 
--- a/tools/mercurial/mach_commands.py
+++ b/tools/mercurial/mach_commands.py
@@ -39,30 +39,16 @@ class VersionControlCommands(object):
         """
         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)
 
-        # Touch a file so we can periodically prompt to update extensions.
-        #
-        # We put this before main command logic because the command can
-        # persistently fail and we want people to get credit for the
-        # intention, not whether the command is bug free.
-        state_dir = os.path.join(self._context.state_dir, 'mercurial')
-        if not os.path.isdir(state_dir):
-            os.makedirs(state_dir)
-
-        state_path = os.path.join(state_dir, 'setup.lastcheck')
-
-        with open(state_path, 'a'):
-            os.utime(state_path, None)
-
         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))