MergeOp: Check commit status separately after merge strategies
The updateChangeStatus method was a little weird, basically following disjoint codepaths depending on the value of the boolean dryRun argument. The first time through, which happened immediately after running the submit strategies, might throw exceptions for missing dependencies or other invalid statuses. The second time through, after executing ref updates, was actually responsible for setting the status on the change objects in the database. (It could theoretically throw in the same cases as the first time it was called, but those should have already thrown already so it's essentially dead code.) Split the first set of checks into a new method, checkMergeStrategyResults, that has an explicit name for what it does, and uses the same problem/failFast structure as we've started adopting elsewhere. Change-Id: I3ea6e5a47d3173749773c0cf7fa175c8048b1a0a
This commit is contained in:
@@ -77,8 +77,9 @@ public abstract class AbstractSubmitByMerge extends AbstractSubmit {
|
||||
PushOneCommit.Result change2 =
|
||||
createChange("Change 2", "a.txt", "other content");
|
||||
submitWithConflict(change2.getChangeId(),
|
||||
"Cannot merge " + change2.getCommit().name() + "\n" +
|
||||
"Change could not be merged due to a path conflict.\n\n" +
|
||||
"Failed to submit 1 change due to the following problems:\n" +
|
||||
"Change " + change2.getChange().getId() + ": " +
|
||||
"Change could not be merged due to a path conflict. " +
|
||||
"Please rebase the change locally " +
|
||||
"and upload the rebased commit for review.");
|
||||
assertThat(getRemoteHead()).isEqualTo(oldHead);
|
||||
|
||||
@@ -16,7 +16,6 @@ package com.google.gerrit.acceptance.rest.change;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.acceptance.TestProjectInput;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
@@ -106,9 +105,9 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change2 =
|
||||
createChange("Change 2", "a.txt", "other content");
|
||||
submitWithConflict(change2.getChangeId(),
|
||||
"Cannot merge " + change2.getCommitId().name() + "\n" +
|
||||
"Change could not be merged due to a path conflict.\n\n" +
|
||||
"Please rebase the change locally and " +
|
||||
"Failed to submit 1 change due to the following problems:\n" +
|
||||
"Change " + change2.getChange().getId() + ": Change could not be " +
|
||||
"merged due to a path conflict. Please rebase the change locally and " +
|
||||
"upload the rebased commit for review.");
|
||||
|
||||
assertThat(getRemoteHead()).isEqualTo(oldHead);
|
||||
@@ -151,9 +150,9 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
PushOneCommit.Result change3 =
|
||||
createChange("Change 3", "b.txt", "different content");
|
||||
submitWithConflict(change3.getChangeId(),
|
||||
"Cannot merge " + change3.getCommitId().name() + "\n" +
|
||||
"Change could not be merged due to a path conflict.\n\n" +
|
||||
"Please rebase the change locally and " +
|
||||
"Failed to submit 1 change due to the following problems:\n" +
|
||||
"Change " + change3.getChange().getId() + ": Change could not be " +
|
||||
"merged due to a path conflict. Please rebase the change locally and " +
|
||||
"upload the rebased commit for review.");
|
||||
|
||||
assertThat(getRemoteHead()).isEqualTo(oldHead);
|
||||
@@ -227,15 +226,13 @@ public class SubmitByCherryPickIT extends AbstractSubmit {
|
||||
// Submit fails; change3 contains the delta "b1" -> "b2", which cannot be
|
||||
// applied against tip.
|
||||
submitWithConflict(change3.getChangeId(),
|
||||
"Cannot merge " + change3.getCommitId().name() + "\n" +
|
||||
"Change could not be merged due to a path conflict.\n\n" +
|
||||
"Please rebase the change locally and " +
|
||||
"Failed to submit 1 change due to the following problems:\n" +
|
||||
"Change " + change3.getChange().getId() + ": Change could not be " +
|
||||
"merged due to a path conflict. Please rebase the change locally and " +
|
||||
"upload the rebased commit for review.");
|
||||
|
||||
ChangeInfo info3 = get(change3.getChangeId(), ListChangesOption.MESSAGES);
|
||||
assertThat(info3.status).isEqualTo(ChangeStatus.NEW);
|
||||
assertThat(Iterables.getLast(info3.messages).message.toLowerCase())
|
||||
.contains("path conflict");
|
||||
|
||||
// Tip has not changed.
|
||||
List<RevCommit> log = getRemoteLog();
|
||||
|
||||
@@ -100,9 +100,10 @@ public class SubmitByFastForwardIT extends AbstractSubmit {
|
||||
assertThat(info.enabled).isNull();
|
||||
|
||||
submitWithConflict(change2.getChangeId(),
|
||||
"Cannot merge " + change2.getCommitId().name() + "\n" +
|
||||
"Project policy requires all submissions to be a fast-forward.\n\n" +
|
||||
"Please rebase the change locally and upload again for review.");
|
||||
"Failed to submit 1 change due to the following problems:\n" +
|
||||
"Change " + change2.getChange().getId() + ": Project policy requires " +
|
||||
"all submissions to be a fast-forward. Please rebase the change " +
|
||||
"locally and upload again for review.");
|
||||
assertThat(getRemoteHead()).isEqualTo(oldHead);
|
||||
assertSubmitter(change.getChangeId(), 1);
|
||||
}
|
||||
|
||||
@@ -181,9 +181,9 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
|
||||
if (isSubmitWholeTopicEnabled()) {
|
||||
submitWithConflict(change1b.getChangeId(),
|
||||
"Cannot merge " + change3.getCommit().name() + "\n" +
|
||||
"Change could not be merged due to a path conflict.\n\n" +
|
||||
"Please rebase the change locally " +
|
||||
"Failed to submit 5 changes due to the following problems:\n" +
|
||||
"Change " + change3.getChange().getId() + ": Change could not be " +
|
||||
"merged due to a path conflict. Please rebase the change locally " +
|
||||
"and upload the rebased commit for review.");
|
||||
} else {
|
||||
submit(change1b.getChangeId());
|
||||
@@ -296,7 +296,11 @@ public class SubmitByMergeIfNecessaryIT extends AbstractSubmitByMerge {
|
||||
"a.txt", "1", "a-topic-here");
|
||||
approve(change3b.getChangeId());
|
||||
|
||||
submitWithConflict(change3a.getChangeId(), "Merge Conflict");
|
||||
String cnt = isSubmitWholeTopicEnabled() ? "2 changes" : "1 change";
|
||||
submitWithConflict(change3a.getChangeId(),
|
||||
"Failed to submit " + cnt + " due to the following problems:\n"
|
||||
+ "Change " + change3a.getChange().getId() + ": depends on change that"
|
||||
+ " was not submitted");
|
||||
|
||||
RevCommit tipbranch = getRemoteLog(project, "branch").get(0);
|
||||
assertThat(tipbranch.getShortMessage()).isEqualTo(
|
||||
|
||||
Reference in New Issue
Block a user