Merge changes from topic 'submit-fixes' into stable-2.12

* changes:
  Submit: Don't assume the "Submitted Together" Tab exists.
  Submit: Give another error message when the change itself has problems
  Submit: Move check for enabling button after rechecking mergeability
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ActionsIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ActionsIT.java
index ddab184..ba98963 100644
--- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ActionsIT.java
+++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ActionsIT.java
@@ -102,8 +102,7 @@
       assertThat(info.enabled).isNull();
       assertThat(info.label).isEqualTo("Submit whole topic");
       assertThat(info.method).isEqualTo("POST");
-      assertThat(info.title).isEqualTo(
-          "See the \"Submitted Together\" tab for problems, specifically see: 2");
+      assertThat(info.title).isEqualTo("Problems with change(s): 2");
     } else {
       noSubmitWholeTopicAssertions(actions, 1);
     }
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java b/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java
index 2a3b7c1..22bdae5 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java
@@ -95,8 +95,10 @@
       "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, specifically see: ";
+      "Problems with change(s): ";
 
   public static class Output {
     transient Change change;
@@ -222,12 +224,13 @@
   }
 
   /**
+   * @param cd the change the user is currently looking at
    * @param cs set of changes to be submitted at once
    * @param identifiedUser 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, IdentifiedUser identifiedUser) {
+  private String problemsForSubmittingChangeset(ChangeData cd, ChangeSet cs,
+      IdentifiedUser identifiedUser) {
     try {
       @SuppressWarnings("resource")
       ReviewDb db = dbProvider.get();
@@ -249,6 +252,11 @@
       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>() {
@@ -310,13 +318,6 @@
         .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(db, cd.change());
@@ -333,8 +334,24 @@
         && !Strings.isNullOrEmpty(topic)
         && topicSize > 1;
 
-    String submitProblems = problemsForSubmittingChangeset(cs,
-        resource.getUser());
+    String submitProblems =
+        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