def print_status()

in git_apple_llvm/am/am_status.py [0:0]


def print_status(remotes: List[str] = ['origin'],
                 target_branch: Optional[str] = None,
                 list_commits: bool = False,
                 query_ci_status: bool = False,
                 graph_format: Optional[str] = None):
    graph = None
    if graph_format:
        # Try to create a new graph. This will throw an exception if the
        # Graphviz package is missing.
        try:
            graph = create_graph(graph_format)
        except Exception as e:
            print(e)
            return
        # Collect all branches across remotes and create corresponding
        # subgraphs. This needs to happen before we add the edges.
        branches: List[str] = []
        for remote in remotes:
            for config in find_am_configs(remote):
                branches.append(config.upstream)
                branches.append(config.target)
                if config.secondary_upstream:
                    branches.append(config.secondary_upstream)
        add_branches(graph, branches)

    for remote in remotes:
        configs: List[AMTargetBranchConfig] = find_am_configs(remote)
        if target_branch:
            configs = list(
                filter(lambda config: config.target == target_branch, configs))
        if len(configs) == 0:
            msg = ''
            if target_branch:
                msg = f'for branch "{target_branch}" from '
            print(f'No automerger configured for {msg}remote "{remote}"')
            return

        ms = find_inflight_merges(remote)
        printed = False
        for config in configs:
            if printed:
                print('')
            if config.secondary_upstream:
                print_zippered_edge_status(config, remote, graph)
                printed = True
                continue
            print_edge_status(config.upstream, config.target,
                              ms, list_commits, remote, graph,
                              query_ci_status=query_ci_status)
            printed = True

    if graph:
        graph.render('automergers', view=True)