summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Kempin <edwin.kempin@sap.com>2013-11-18 16:03:09 +0100
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-11-19 00:55:44 +0000
commit9dff074c73ba59f17d8e0430cae04b5a6d1ac32c (patch)
tree5fd80dbb2673030dd238e273e6f99a6a51f5eb99
parentebfff02c75d02c9e9ed2b54053cf696fd7b8794f (diff)
Fix updating changes that fail to merge
If a submitted change fails to merge due an error (e.g. inconsistent data or a pre merge validation found an issue) the change state should be set back to 'New', but it stays as 'Submitted, Merge Pending'. It should also display a proper error message to the user doing the submit and add a change message to the change that contains the error message. Both is currently not happening and the user has no idea why the change got stuck in 'Submitted, Merge Pending' state. This change ensures that all changes which cannot be merged due to an error are properly updated. Change-Id: Idd8da6a4cd089d2a7b09cbb60342612f1c5256e9 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com> (cherry picked from commit 851f7017fd8728616406c605bd5b906706894bc7)
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java
index aa334f38fa..cf8a16baa5 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/MergeOp.java
@@ -27,6 +27,7 @@ import com.google.common.base.Objects;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.gerrit.common.ChangeHooks;
@@ -144,6 +145,7 @@ public class MergeOp {
private final ListMultimap<SubmitType, CodeReviewCommit> toMerge;
private final List<CodeReviewCommit> potentiallyStillSubmittable;
private final Map<Change.Id, CodeReviewCommit> commits;
+ private final List<Change> toUpdate;
private ReviewDb db;
private Repository repo;
private RevWalk rw;
@@ -202,6 +204,7 @@ public class MergeOp {
toMerge = ArrayListMultimap.create();
potentiallyStillSubmittable = new ArrayList<CodeReviewCommit>();
commits = new HashMap<Change.Id, CodeReviewCommit>();
+ toUpdate = Lists.newArrayList();
}
private void setDestProject() throws MergeException {
@@ -269,6 +272,8 @@ public class MergeOp {
toMerge.putAll(toMergeNextTurn);
}
+ updateChangeStatus(toUpdate);
+
for (final CodeReviewCommit commit : potentiallyStillSubmittableOnNextRun) {
final Capable capable = isSubmitStillPossible(commit);
if (capable != Capable.OK) {
@@ -447,6 +452,7 @@ public class MergeOp {
if (chg.currentPatchSetId() == null) {
commits.put(changeId, CodeReviewCommit
.error(CommitMergeStatus.NO_PATCH_SET));
+ toUpdate.add(chg);
continue;
}
@@ -460,6 +466,7 @@ public class MergeOp {
|| ps.getRevision().get() == null) {
commits.put(changeId, CodeReviewCommit
.error(CommitMergeStatus.NO_PATCH_SET));
+ toUpdate.add(chg);
continue;
}
@@ -470,6 +477,7 @@ public class MergeOp {
} catch (IllegalArgumentException iae) {
commits.put(changeId, CodeReviewCommit
.error(CommitMergeStatus.NO_PATCH_SET));
+ toUpdate.add(chg);
continue;
}
@@ -485,6 +493,7 @@ public class MergeOp {
//
commits.put(changeId, CodeReviewCommit
.error(CommitMergeStatus.REVISION_GONE));
+ toUpdate.add(chg);
continue;
}
@@ -495,6 +504,7 @@ public class MergeOp {
log.error("Invalid commit " + id.name() + " on " + chg.getKey(), e);
commits.put(changeId, CodeReviewCommit
.error(CommitMergeStatus.REVISION_GONE));
+ toUpdate.add(chg);
continue;
}
@@ -503,6 +513,7 @@ public class MergeOp {
mergeValidators.validatePreMerge(repo, commit, destProject, destBranch, ps.getId());
} catch (MergeValidationException mve) {
commits.put(changeId, CodeReviewCommit.error(mve.getStatus()));
+ toUpdate.add(chg);
continue;
}
@@ -535,6 +546,7 @@ public class MergeOp {
if (submitType == null) {
commits.put(changeId,
CodeReviewCommit.error(CommitMergeStatus.NO_SUBMIT_TYPE));
+ toUpdate.add(chg);
continue;
}