def get_components_for_repo_and_branch(git_command, branch_packages, branch_regex):
  """
  Create a components dict from the specified branch
  """
  try:
    if branch_packages.startswith("refs/sandbox/"):
      branch_packages = branch_packages[len("refs/"):]
    else:
      branch_packages = GITREMOTE + "/" + branch_packages

    component_text = None
    component_regex_text = None

    try:
      component_text = git_command.show(branch_packages + \
        ":components-packages.txt")
    except Exception, e:
      pass
    component_dict = components.parse_component_text(component_text)
    for i in component_dict.keys():
      if i in IGNORED_COMPONENTS:
        del component_dict[i]

    try:
      component_regex_text = git_command.show("origin/%s:components-regex.txt" % branch_regex)
    except Exception, e:
      pass
def get_components_for_repo_and_branch(git_command, branch_packages,
                                       branch_regex):
    """
  Create a components dict from the specified branch
  """
    try:
        if branch_packages.startswith("refs/sandbox/"):
            branch_packages = branch_packages[len("refs/"):]
        else:
            branch_packages = GITREMOTE + "/" + branch_packages

        component_text = None
        component_regex_text = None

        try:
            component_text = git_command.show(branch_packages + \
              ":components-packages.txt")
        except Exception, e:
            pass
        component_dict = components.parse_component_text(component_text)
        for i in component_dict.keys():
            if i in IGNORED_COMPONENTS:
                del component_dict[i]

        try:
            component_regex_text = git_command.show(
                "origin/%s:components-regex.txt" % branch_regex)
        except Exception, e:
            pass
    try:
      component_text = git_command.show(branch_packages + \
        ":components-packages.txt")
    except Exception, e:
      pass
    component_dict = components.parse_component_text(component_text)
    for i in component_dict.keys():
      if i in IGNORED_COMPONENTS:
        del component_dict[i]

    try:
      component_regex_text = git_command.show("origin/%s:components-regex.txt" % branch_regex)
    except Exception, e:
      pass
    component_regex_dict = components.parse_component_text(component_regex_text, starting_dict = OrderedDict())
    component_regex_high_dict = components.get_high_priority_components(component_regex_dict)
    component_regex_normal_dict = components.get_normal_priority_components(component_regex_dict)
    return {"packages": component_dict, "regexhigh": component_regex_high_dict, "regexnormal": component_regex_normal_dict}
  except Exception, e:
    logger.error("Couldn't retrieve components file: %s", e)
    return {}

def pick_owner(component, author):
  """From a component, pick the owner.  We don't consider the author of the commit for ownership."""
  for consider in component.owners:
    if author != consider:
      return consider
  return AUTHOR_NO_ONE

def pick_owner_all(component, author):
        try:
            component_text = git_command.show(branch_packages + \
              ":components-packages.txt")
        except Exception, e:
            pass
        component_dict = components.parse_component_text(component_text)
        for i in component_dict.keys():
            if i in IGNORED_COMPONENTS:
                del component_dict[i]

        try:
            component_regex_text = git_command.show(
                "origin/%s:components-regex.txt" % branch_regex)
        except Exception, e:
            pass
        component_regex_dict = components.parse_component_text(
            component_regex_text, starting_dict=OrderedDict())
        component_regex_high_dict = components.get_high_priority_components(
            component_regex_dict)
        component_regex_normal_dict = components.get_normal_priority_components(
            component_regex_dict)
        return {
            "packages": component_dict,
            "regexhigh": component_regex_high_dict,
            "regexnormal": component_regex_normal_dict
        }
    except Exception, e:
        logger.error("Couldn't retrieve components file: %s", e)
        return {}


def pick_owner(component, author):