Submit: improve submit button label when having parents

Change-Id: I5f9952d6f0746e586c92df727dfcfbcaade308a8
diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt
index 7b3431e..2de50ac 100644
--- a/Documentation/config-gerrit.txt
+++ b/Documentation/config-gerrit.txt
@@ -863,6 +863,13 @@
 +
 Default is "Submit".
 
+[[change.submitLabelWithParents]]change.submitLabelWithParents::
++
+Label name for the submit button if the change has parents which will
+be submitted together with this change.
++
+Default is "Submit including parents".
+
 [[change.submitTooltip]]change.submitTooltip::
 +
 Tooltip for the submit button.  Variables available for replacement
@@ -903,9 +910,12 @@
 If `change.submitWholeTopic` is configuerd to true and a change has a
 topic, this configuration determines the tooltip for the submit button
 instead of `change.submitTooltip`. The variable `${topicSize}` is available
-for the number of changes to be submitted.
+for the number of changes in the same topic to be submitted. The number of
+all changes to be submitted is in the variable `${submitSize}`.
 +
-Defaults to "Submit all ${topicSize} changes within the topic".
+Defaults to "Submit all ${topicSize} changes of the same topic
+(${submitSize} changes including ancestors and other
+changes related by topic)".
 
 [[change.replyLabel]]change.replyLabel::
 +
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 24bb72b..d6c8dac 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
@@ -154,7 +154,11 @@
       int nrChanges) {
     ActionInfo info = actions.get("submit");
     assertThat(info.enabled).isTrue();
-    assertThat(info.label).isEqualTo("Submit");
+    if (nrChanges == 1) {
+      assertThat(info.label).isEqualTo("Submit");
+    } else {
+      assertThat(info.label).isEqualTo("Submit including parents");
+    }
     assertThat(info.method).isEqualTo("POST");
     if (nrChanges == 1) {
       assertThat(info.title).isEqualTo("Submit patch set 1 into master");
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 6bba656..2d7db67 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
@@ -102,6 +102,7 @@
   private final AccountsCollection accounts;
   private final ChangesCollection changes;
   private final String label;
+  private final String labelWithParents;
   private final ParameterizedString titlePattern;
   private final ParameterizedString titlePatternWithAncestors;
   private final String submitTopicLabel;
@@ -133,6 +134,10 @@
     this.label = MoreObjects.firstNonNull(
         Strings.emptyToNull(cfg.getString("change", null, "submitLabel")),
         "Submit");
+    this.labelWithParents = MoreObjects.firstNonNull(
+        Strings.emptyToNull(
+            cfg.getString("change", null, "submitLabelWithParents")),
+        "Submit including parents");
     this.titlePattern = new ParameterizedString(MoreObjects.firstNonNull(
         cfg.getString("change", null, "submitTooltip"),
         DEFAULT_TOOLTIP));
@@ -319,7 +324,9 @@
         resource.getUser());
     if (submitProblems != null) {
       return new UiAction.Description()
-        .setLabel(treatWithTopic ? submitTopicLabel : label)
+        .setLabel(treatWithTopic
+            ? submitTopicLabel : (cs.size() > 1)
+                ? labelWithParents : label)
         .setTitle(submitProblems)
         .setVisible(true)
         .setEnabled(false);
@@ -345,7 +352,7 @@
       ParameterizedString tp = cs.size() > 1 ? titlePatternWithAncestors :
           titlePattern;
       return new UiAction.Description()
-        .setLabel(label)
+        .setLabel(cs.size() > 1 ? labelWithParents : label)
         .setTitle(Strings.emptyToNull(tp.replace(params)))
         .setVisible(true)
         .setEnabled(Boolean.TRUE.equals(enabled));