Make MergeConflictException a ResourceConflictException

This means we don't have to unwrap this exception type when used from
a BatchUpdate, since BatchUpdate propagates RestApiExceptions.

Change-Id: I3b655308ec22913bee0b9114074d192360466893
This commit is contained in:
Dave Borowitz
2015-10-28 15:48:07 -04:00
parent a7e5f122fa
commit f0112b9a74
7 changed files with 18 additions and 20 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.git.strategy;
import com.google.common.collect.Lists;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.MergeConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -29,7 +30,6 @@ import com.google.gerrit.server.git.BatchUpdate.RepoContext;
import com.google.gerrit.server.git.CodeReviewCommit;
import com.google.gerrit.server.git.CommitMergeStatus;
import com.google.gerrit.server.git.GroupCollector;
import com.google.gerrit.server.git.MergeConflictException;
import com.google.gerrit.server.git.MergeException;
import com.google.gerrit.server.git.MergeIdenticalTreeException;
import com.google.gerrit.server.git.MergeTip;

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.git.strategy;
import com.google.common.collect.Lists;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.extensions.restapi.MergeConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -24,7 +25,6 @@ import com.google.gerrit.server.change.RebaseChangeOp;
import com.google.gerrit.server.git.BatchUpdate;
import com.google.gerrit.server.git.CodeReviewCommit;
import com.google.gerrit.server.git.CommitMergeStatus;
import com.google.gerrit.server.git.MergeConflictException;
import com.google.gerrit.server.git.MergeException;
import com.google.gerrit.server.git.MergeTip;
import com.google.gerrit.server.git.RebaseSorter;
@@ -111,15 +111,12 @@ public class RebaseIfNecessary extends SubmitStrategy {
newCommits.put(newPatchSet.getId().getParentKey(),
mergeTip.getCurrentTip());
setRefLogIdent();
} catch (UpdateException e) {
if (e.getCause() instanceof MergeConflictException) {
n.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
}
throw new MergeException("Cannot rebase " + n.name(), e);
} catch (MergeConflictException e) {
n.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
throw new MergeException(
"Cannot rebase " + n.name() + ": " + e.getMessage(), e);
} catch (NoSuchChangeException | OrmException | IOException
| RestApiException e) {
// TODO(dborowitz): Allow Submit to unwrap ResourceConflictException
// so it can turn into a 409.
| RestApiException | UpdateException e) {
throw new MergeException("Cannot rebase " + n.name(), e);
}
}