private void checkForParent(XmlHolder holder) throws AmbariException {
    RepositoryVersionEntity entity = holder.entity;

    // only STANDARD types don't have a parent
    if (entity.getType() == RepositoryType.STANDARD) {
      return;
    }

    List<RepositoryVersionEntity> entities = s_repoVersionDAO.findByStackAndType(
        entity.getStackId(), RepositoryType.STANDARD);

    if (entities.isEmpty()) {
      throw new IllegalArgumentException(String.format("Patch %s was uploaded, but there are no repositories for %s",
          entity.getVersion(), entity.getStackId().toString()));
    }

    List<RepositoryVersionEntity> matching = new ArrayList<>();

    boolean emptyCompatible = StringUtils.isBlank(holder.xml.release.compatibleWith);

    for (RepositoryVersionEntity version : entities) {
      String baseVersion = version.getVersion();
      if (baseVersion.lastIndexOf('-') > -1) {
        baseVersion = baseVersion.substring(0,  baseVersion.lastIndexOf('-'));
      }

      if (emptyCompatible) {
        if (baseVersion.equals(holder.xml.release.version)) {
          matching.add(version);
        }
      } else {
        if (baseVersion.matches(holder.xml.release.compatibleWith)) {
          matching.add(version);
        }
      }
    }

    RepositoryVersionEntity parent = null;

    if (matching.isEmpty()) {
      String format = "No versions matched pattern %s";

      throw new IllegalArgumentException(String.format(format,
          emptyCompatible ? holder.xml.release.version : holder.xml.release.compatibleWith));
    } else if (matching.size() > 1) {

      Function<RepositoryVersionEntity, String> function = new Function<RepositoryVersionEntity, String>() {
        @Override
        public String apply(RepositoryVersionEntity input) {
          return input.getVersion();
        }
      };

      Collection<String> versions = Collections2.transform(matching, function);

      List<RepositoryVersionEntity> used = s_repoVersionDAO.findByServiceDesiredVersion(matching);

      if (used.isEmpty()) {
        throw new IllegalArgumentException(String.format("Could not determine which version " +
          "to associate patch %s. Remove one of %s and try again.",
          entity.getVersion(), StringUtils.join(versions, ", ")));
      } else if (used.size() > 1) {
        Collection<String> usedVersions = Collections2.transform(used, function);

        throw new IllegalArgumentException(String.format("Patch %s was found to match more " +
            "than one repository in use: %s. Move all services to a common version and try again.",
            entity.getVersion(), StringUtils.join(usedVersions, ", ")));
      } else {
        parent = used.get(0);
        LOG.warn("Patch {} was found to match more than one repository in {}. " +
            "Repository {} is in use and will be the parent.", entity.getVersion(),
               StringUtils.join(versions, ", "), parent.getVersion());
      }
    } else {
      parent = matching.get(0);
    }

    if (null == parent) {
      throw new IllegalArgumentException(String.format("Could not find any parent repository for %s.",
          entity.getVersion()));
    }

    entity.setParent(parent);
  }
In the case of a patch, check if there is a parent repo.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java