def GetMasterMap():
    if (not options.bot):
        change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None)
        masters = presubmit_support.DoGetTryMasters(change, change.LocalPaths(), settings.GetRoot(), None, None, options.verbose, sys.stdout)
        if masters:
            return masters
        options.bot = presubmit_support.DoGetTrySlaves(change, change.LocalPaths(), settings.GetRoot(), None, None, options.verbose, sys.stdout)
        if (not options.bot):
            cq_cfg = os.path.join(change.RepositoryRoot(), 'infra', 'config', 'cq.cfg')
            if os.path.exists(cq_cfg):
                masters = {}
                cq_masters = commit_queue.get_master_builder_map(cq_cfg, include_experimental=False, include_triggered=False)
                for (master, builders) in cq_masters.iteritems():
                    for builder in builders:
                        masters.setdefault(master, {})[builder] = ['defaulttests']
                if masters:
                    print(('Loaded default bots from CQ config (%s)' % cq_cfg))
                    return masters
                else:
                    print(('CQ config exists (%s) but has no try bots listed' % cq_cfg))
    if (not options.bot):
        parser.error('No default try builder to try, use --bot')
    builders_and_tests = {}
    old_style = filter((lambda x: isinstance(x, basestring)), options.bot)
    new_style = filter((lambda x: isinstance(x, tuple)), options.bot)
    for bot in old_style:
        if (':' in bot):
            parser.error('Specifying testfilter is no longer supported')
        elif (',' in bot):
            parser.error('Specify one bot per --bot flag')
        else:
            builders_and_tests.setdefault(bot, [])
    for (bot, tests) in new_style:
        builders_and_tests.setdefault(bot, []).extend(tests)
    return {options.master: builders_and_tests}
def GetMasterMap():
    if (not options.bot):
        change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None)
        masters = presubmit_support.DoGetTryMasters(change, change.LocalPaths(), settings.GetRoot(), None, None, options.verbose, sys.stdout)
        if masters:
            return masters
        options.bot = presubmit_support.DoGetTrySlaves(change, change.LocalPaths(), settings.GetRoot(), None, None, options.verbose, sys.stdout)
        if (not options.bot):
            cq_cfg = os.path.join(change.RepositoryRoot(), 'infra', 'config', 'cq.cfg')
            if os.path.exists(cq_cfg):
                masters = {}
                cq_masters = commit_queue.get_master_builder_map(cq_cfg, include_experimental=False, include_triggered=False)
                for (master, builders) in cq_masters.iteritems():
                    for builder in builders:
                        masters.setdefault(master, {})[builder] = ['defaulttests']
                if masters:
                    print(('Loaded default bots from CQ config (%s)' % cq_cfg))
                    return masters
                else:
                    print(('CQ config exists (%s) but has no try bots listed' % cq_cfg))
    if (not options.bot):
        parser.error('No default try builder to try, use --bot')
    builders_and_tests = {}
    old_style = filter((lambda x: isinstance(x, basestring)), options.bot)
    new_style = filter((lambda x: isinstance(x, tuple)), options.bot)
    for bot in old_style:
        if (':' in bot):
            parser.error('Specifying testfilter is no longer supported')
        elif (',' in bot):
            parser.error('Specify one bot per --bot flag')
        else:
            builders_and_tests.setdefault(bot, [])
    for (bot, tests) in new_style:
        builders_and_tests.setdefault(bot, []).extend(tests)
    return {options.master: builders_and_tests}