Bug 1176642 - Use deferred imports for taskcluster mach commands; r=glandium

Tracing imports reveals that this file accounts for a non-trivial amount
of extra imports when mach starts. Deferring imports makes many of them
go away.

--HG--
extra : commitid : KT7CfnsUFGA
extra : rebase_source : d631e0a94bc4656fd69815e6808e5d42e0f0b4c2
This commit is contained in:
Gregory Szorc 2015-06-21 17:09:58 -07:00
parent a19bee3a08
commit 70e857cb9e

View File

@ -16,13 +16,6 @@ from mach.decorators import (
Command,
)
from taskcluster_graph.commit_parser import parse_commit
from taskcluster_graph.slugid import slugid
from taskcluster_graph.slugidjar import SlugidJar
from taskcluster_graph.from_now import json_time_from_now, current_json_time
from taskcluster_graph.templates import Templates
import taskcluster_graph.build_task
ROOT = os.path.dirname(os.path.realpath(__file__))
GECKO = os.path.realpath(os.path.join(ROOT, '..', '..'))
@ -140,6 +133,13 @@ class DecisionTask(object):
help='email address of who owns this graph')
@CommandArgument('task', help="Path to decision task to run.")
def run_task(self, **params):
from taskcluster_graph.slugidjar import SlugidJar
from taskcluster_graph.from_now import (
json_time_from_now,
current_json_time,
)
from taskcluster_graph.templates import Templates
templates = Templates(ROOT)
# Template parameters used when expanding the graph
parameters = dict(gaia_info().items() + {
@ -191,6 +191,15 @@ class Graph(object):
@CommandArgument('--extend-graph',
action="store_true", dest="ci", help='Omit create graph arguments')
def create_graph(self, **params):
from taskcluster_graph.commit_parser import parse_commit
from taskcluster_graph.slugid import slugid
from taskcluster_graph.from_now import (
json_time_from_now,
current_json_time,
)
from taskcluster_graph.templates import Templates
import taskcluster_graph.build_task
project = params['project']
message = params.get('message', '') if project == 'try' else DEFAULT_TRY
@ -409,6 +418,9 @@ class CIBuild(object):
@CommandArgument('build_task',
help='path to build task definition')
def create_ci_build(self, **params):
from taskcluster_graph.templates import Templates
import taskcluster_graph.build_task
templates = Templates(ROOT)
# TODO handle git repos
head_repository = params['head_repository']