def bucket_states_by_commit()

in tools/dart/dart_buildbot_helper.py [0:0]


def bucket_states_by_commit(builder_states):
  commit_buckets = {}
  for builder_state in builder_states:
    previous_revision = None
    for state in reversed(builder_state):
      # If the builder doesn't have a name, ignore it.
      if state.builder_name == None:
        continue
      revisions = []
      # The build bot API doesn't return a list of revisions for a build so
      # we'll have to associate commits to builds manually.
      if previous_revision == None:
        revisions.append(state.revision)
      else:
        revisions = get_dart_sdk_commits_in_range(previous_revision, state.revision)
      for rev in revisions:
        if rev not in commit_buckets:
          commit_buckets[rev] = [state]
        else:
          commit_buckets[rev].append(state)
      previous_revision = state.revision
  bots_completed = max([len(v) for k,v in commit_buckets.items()])

  # We only care about commits that have been built and tested on all
  # configurations.
  commit_buckets = { k: v for k, v in commit_buckets.items() if len(v) == bots_completed }
  return commit_buckets