Bug 1383880: use a vcs-compatible reader in decision tasks; r?gps draft
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 07 Sep 2017 18:28:22 +0000
changeset 668276 0c6079a372cde05afa80fddb97cb817969c31a33
parent 668275 d4b8ad765a20ddc522fae58df9a73e23175565e2
child 668277 d3eabcbd8cd9c01db3a3528f6a34ad755407e30d
push id80998
push userdmitchell@mozilla.com
push dateThu, 21 Sep 2017 12:49:52 +0000
reviewersgps
bugs1383880
milestone57.0a1
Bug 1383880: use a vcs-compatible reader in decision tasks; r?gps This continues to use a file-based reader when run locally. MozReview-Commit-ID: CJuYKDj2E3n
taskcluster/taskgraph/optimize.py
--- a/taskcluster/taskgraph/optimize.py
+++ b/taskcluster/taskgraph/optimize.py
@@ -21,17 +21,17 @@ from collections import defaultdict
 from .graph import Graph
 from . import files_changed
 from .taskgraph import TaskGraph
 from .util.seta import is_low_value_task
 from .util.taskcluster import find_task_id
 from .util.parameterization import resolve_task_references
 from mozbuild.util import memoize
 from slugid import nice as slugid
-from mozbuild.frontend import reader
+from mozbuild.base import MozbuildObject
 
 logger = logging.getLogger(__name__)
 
 TOPSRCDIR = os.path.abspath(os.path.join(__file__, '../../../'))
 
 
 def optimize_task_graph(target_task_graph, params, do_not_optimize,
                         existing_tasks=None, strategies=None):
@@ -353,18 +353,22 @@ class SkipUnlessChanged(OptimizationStra
 
 
 class SkipUnlessSchedules(OptimizationStrategy):
 
     @memoize
     def scheduled_by_push(self, repository, revision):
         changed_files = files_changed.get_changed_files(repository, revision)
 
-        config = reader.EmptyConfig(TOPSRCDIR)
-        rdr = reader.BuildReader(config)
+        mbo = MozbuildObject.from_environment()
+        # the decision task has a sparse checkout, so, mozbuild_reader will use
+        # a MercurialRevisionFinder with revision '.', which should be the same
+        # as `revision`; in other circumstances, it will use a default reader
+        rdr = mbo.mozbuild_reader(config_mode='empty')
+
         components = set()
         for p, m in rdr.files_info(changed_files).items():
             components |= set(m['SCHEDULES'].components)
 
         return components
 
     def should_remove_task(self, task, params, conditions):
         if params.get('pushlog_id') == -1: