Merge "Merge branch 'stable-2.12'"
This commit is contained in:
		@@ -100,8 +100,10 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
 | 
			
		||||
      "This change depends on other hidden changes which are not ready";
 | 
			
		||||
  private static final String CLICK_FAILURE_TOOLTIP =
 | 
			
		||||
      "Clicking the button would fail";
 | 
			
		||||
  private static final String CHANGE_UNMERGEABLE =
 | 
			
		||||
      "Problems with integrating this change";
 | 
			
		||||
  private static final String CHANGES_NOT_MERGEABLE =
 | 
			
		||||
      "See the \"Submitted Together\" tab for problems, specially see: ";
 | 
			
		||||
      "Problems with change(s): ";
 | 
			
		||||
 | 
			
		||||
  public static class Output {
 | 
			
		||||
    transient Change change;
 | 
			
		||||
@@ -246,11 +248,12 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @param cd the change the user is currently looking at
 | 
			
		||||
   * @param cs set of changes to be submitted at once
 | 
			
		||||
   * @param user the user who is checking to submit
 | 
			
		||||
   * @return a reason why any of the changes is not submittable or null
 | 
			
		||||
   */
 | 
			
		||||
  private String problemsForSubmittingChangeset(ChangeSet cs,
 | 
			
		||||
  private String problemsForSubmittingChangeset(ChangeData cd, ChangeSet cs,
 | 
			
		||||
      CurrentUser user) {
 | 
			
		||||
    try {
 | 
			
		||||
      @SuppressWarnings("resource")
 | 
			
		||||
@@ -271,6 +274,11 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
 | 
			
		||||
      if (unmergeable == null) {
 | 
			
		||||
        return CLICK_FAILURE_TOOLTIP;
 | 
			
		||||
      } else if (!unmergeable.isEmpty()) {
 | 
			
		||||
        for (ChangeData c : unmergeable) {
 | 
			
		||||
          if (c.change().getKey().equals(cd.change().getKey())) {
 | 
			
		||||
            return CHANGE_UNMERGEABLE;
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        return CHANGES_NOT_MERGEABLE + Joiner.on(", ").join(
 | 
			
		||||
            Iterables.transform(unmergeable,
 | 
			
		||||
                new Function<ChangeData, String>() {
 | 
			
		||||
@@ -332,13 +340,6 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
 | 
			
		||||
        .setVisible(false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Boolean enabled;
 | 
			
		||||
    try {
 | 
			
		||||
      enabled = cd.isMergeable();
 | 
			
		||||
    } catch (OrmException e) {
 | 
			
		||||
      throw new OrmRuntimeException("Could not determine mergeability", e);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ChangeSet cs;
 | 
			
		||||
    try {
 | 
			
		||||
      cs = mergeSuperSet.completeChangeSet(
 | 
			
		||||
@@ -357,7 +358,23 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
 | 
			
		||||
        && topicSize > 1;
 | 
			
		||||
 | 
			
		||||
    String submitProblems =
 | 
			
		||||
        problemsForSubmittingChangeset(cs, resource.getUser());
 | 
			
		||||
        problemsForSubmittingChangeset(cd, cs, resource.getUser());
 | 
			
		||||
 | 
			
		||||
    Boolean enabled;
 | 
			
		||||
    try {
 | 
			
		||||
      // Recheck mergeability rather than using value stored in the index,
 | 
			
		||||
      // which may be stale.
 | 
			
		||||
      // TODO(dborowitz): This is ugly; consider providing a way to not read
 | 
			
		||||
      // stored fields from the index in the first place.
 | 
			
		||||
      // cd.setMergeable(null);
 | 
			
		||||
      // That was done in unmergeableChanges which was called by
 | 
			
		||||
      // problemsForSubmittingChangeset, so now it is safe to read from
 | 
			
		||||
      // the cache, as it yields the same result.
 | 
			
		||||
      enabled = cd.isMergeable();
 | 
			
		||||
    } catch (OrmException e) {
 | 
			
		||||
      throw new OrmRuntimeException("Could not determine mergeability", e);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (submitProblems != null) {
 | 
			
		||||
      return new UiAction.Description()
 | 
			
		||||
        .setLabel(treatWithTopic
 | 
			
		||||
 
 | 
			
		||||
@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.restapi.IdString;
 | 
			
		||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
 | 
			
		||||
import com.google.gerrit.extensions.restapi.RestView;
 | 
			
		||||
import com.google.inject.Inject;
 | 
			
		||||
import com.google.inject.Provider;
 | 
			
		||||
import com.google.inject.Singleton;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -28,24 +29,24 @@ import java.io.IOException;
 | 
			
		||||
public class TagsCollection implements
 | 
			
		||||
    ChildCollection<ProjectResource, TagResource> {
 | 
			
		||||
  private final DynamicMap<RestView<TagResource>> views;
 | 
			
		||||
  private final ListTags list;
 | 
			
		||||
  private final Provider<ListTags> list;
 | 
			
		||||
 | 
			
		||||
  @Inject
 | 
			
		||||
  public TagsCollection(DynamicMap<RestView<TagResource>> views,
 | 
			
		||||
     ListTags list) {
 | 
			
		||||
     Provider<ListTags> list) {
 | 
			
		||||
    this.views = views;
 | 
			
		||||
    this.list = list;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public RestView<ProjectResource> list() throws ResourceNotFoundException {
 | 
			
		||||
    return list;
 | 
			
		||||
    return list.get();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
  public TagResource parse(ProjectResource resource, IdString id)
 | 
			
		||||
      throws ResourceNotFoundException, IOException {
 | 
			
		||||
    return new TagResource(resource.getControl(), list.get(resource, id));
 | 
			
		||||
    return new TagResource(resource.getControl(), list.get().get(resource, id));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -997,11 +997,11 @@ public void setPatchSets(Collection<PatchSet> patchSets) {
 | 
			
		||||
        return Collections.emptySet();
 | 
			
		||||
      }
 | 
			
		||||
      editsByUser = new HashSet<>();
 | 
			
		||||
      Change.Id id = change.getId();
 | 
			
		||||
      Change.Id id = checkNotNull(change.getId());
 | 
			
		||||
      try (Repository repo = repoManager.openRepository(project())) {
 | 
			
		||||
        for (String ref
 | 
			
		||||
            : repo.getRefDatabase().getRefs(RefNames.REFS_USERS).keySet()) {
 | 
			
		||||
          if (Change.Id.fromEditRefPart(ref).equals(id)) {
 | 
			
		||||
          if (id.equals(Change.Id.fromEditRefPart(ref))) {
 | 
			
		||||
            editsByUser.add(Account.Id.fromRefPart(ref));
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user