summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2016-06-02 00:22:12 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-06-02 00:22:13 +0000
commit41cf77d426cc188eea5eb172c536ae65b9ba173e (patch)
treee8c8b5ca0cef2ad84b6fb21ccf37fe3dc5ff65cc
parenta0d78e524d09d3d7919f989dbc731ec6f4ace8df (diff)
parent6c53c794d56863e2172b1f159c2ecdf1317b70ec (diff)
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
-rw-r--r--gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/change/ActionsIT.java3
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/change/Submit.java41
2 files changed, 30 insertions, 14 deletions
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 ddab184183..ba98963a17 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 @@ public class ActionsIT extends AbstractDaemonTest {
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 2a3b7c199c..22bdae506f 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 @@ 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, specifically see: ";
+ "Problems with change(s): ";
public static class Output {
transient Change change;
@@ -222,12 +224,13 @@ 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 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 @@ 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>() {
@@ -310,13 +318,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(db, cd.change());
@@ -333,8 +334,24 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
&& !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