Bug 1480187 - Fix mach try again when using multiple source checkouts. r=ahal
authorTudor-Gabriel Vîjială <tvijiala@mozilla.com>
Mon, 06 Aug 2018 10:44:29 +0100
changeset 431412 5312e71473c4
parent 431411 e477368edf31
child 431413 1283ee4cfb6b
push id34442
push useraiakab@mozilla.com
push dateTue, 14 Aug 2018 21:59:35 +0000
treeherdermozilla-central@fa2f3d22c156 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1480187
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1480187 - Fix mach try again when using multiple source checkouts. r=ahal MozReview-Commit-ID: AV7ynmTSY1x
tools/tryselect/push.py
tools/tryselect/selectors/again.py
--- a/tools/tryselect/push.py
+++ b/tools/tryselect/push.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function
 
+import hashlib
 import json
 import os
 import sys
 
 from mozboot.util import get_state_dir
 from mozbuild.base import MozbuildObject
 from mozversioncontrol import get_repository_object, MissingVCSExtension
 
@@ -39,17 +40,19 @@ UNCOMMITTED_CHANGES = """
 ERROR please commit changes before continuing
 """.strip()
 
 MAX_HISTORY = 10
 
 here = os.path.abspath(os.path.dirname(__file__))
 build = MozbuildObject.from_environment(cwd=here)
 vcs = get_repository_object(build.topsrcdir)
-history_path = os.path.join(get_state_dir()[0], 'history', 'try_task_configs.json')
+topsrcdir_hash = hashlib.sha256(os.path.abspath(build.topsrcdir)).hexdigest()
+history_path = os.path.join(get_state_dir()[0], 'history', topsrcdir_hash, 'try_task_configs.json')
+old_history_path = os.path.join(get_state_dir()[0], 'history', 'try_task_configs.json')
 
 
 def write_task_config(try_task_config):
     config_path = os.path.join(vcs.path, 'try_task_config.json')
     with open(config_path, 'w') as fh:
         json.dump(try_task_config, fh, indent=2, separators=(',', ':'))
         fh.write('\n')
     return config_path
--- a/tools/tryselect/selectors/again.py
+++ b/tools/tryselect/selectors/again.py
@@ -1,19 +1,20 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import json
 import os
+import shutil
 
 from ..cli import BaseTryParser
-from ..push import push_to_try, history_path
+from ..push import push_to_try, history_path, old_history_path
 
 
 class AgainParser(BaseTryParser):
     name = 'again'
     arguments = [
         [['--index'],
          {'default': 0,
           'type': int,
@@ -32,16 +33,22 @@ class AgainParser(BaseTryParser):
           'action': 'store_true',
           'help': "Remove all history and exit",
           }],
     ]
     common_groups = ['push']
 
 
 def run_try_again(index=0, purge=False, list_configs=False, message='{msg}', **pushargs):
+    # Try to move existing history file from the old location to the new one.
+    if os.path.isfile(old_history_path) and not os.path.isfile(history_path):
+        if not os.path.isdir(os.path.dirname(history_path)):
+            os.makedirs(os.path.dirname(history_path))
+        shutil.move(old_history_path, history_path)
+
     if purge:
         os.remove(history_path)
         return
 
     if not os.path.isfile(history_path):
         print("error: history file not found: {}".format(history_path))
         return 1