Rename MergeException to IntegrationException
It's confusing to have MergeException and MergeConflictException be two different types that don't share a hierarchy: if I have a merge conflict, which one should I throw? We've already started using the term "integrate" to mean "submit a change and make it a part of the target branch". This is specifically the situation in which MergeException was used, so let's just rename it to IntegrationException. Change-Id: I344c70bf8ffeb3a2823a65b5fcf09ea9bff82e72
This commit is contained in:
@@ -25,7 +25,7 @@ import com.google.gerrit.extensions.webui.UiAction;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.UpdateException;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
@@ -87,7 +87,7 @@ public class CherryPick implements RestModifyView<RevisionResource, CherryPickIn
|
||||
return json.create(ChangeJson.NO_OPTIONS).format(cherryPickedChangeId);
|
||||
} catch (InvalidChangeOperationException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
} catch (MergeException | NoSuchChangeException e) {
|
||||
} catch (IntegrationException | NoSuchChangeException e) {
|
||||
throw new ResourceConflictException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.gerrit.server.git.BatchUpdate;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeIdenticalTreeException;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.git.UpdateException;
|
||||
@@ -112,7 +112,7 @@ public class CherryPickChange {
|
||||
final RefControl refControl) throws NoSuchChangeException,
|
||||
OrmException, MissingObjectException,
|
||||
IncorrectObjectTypeException, IOException,
|
||||
InvalidChangeOperationException, MergeException, UpdateException,
|
||||
InvalidChangeOperationException, IntegrationException, UpdateException,
|
||||
RestApiException {
|
||||
|
||||
if (Strings.isNullOrEmpty(ref)) {
|
||||
@@ -195,7 +195,7 @@ public class CherryPickChange {
|
||||
return newChange.getId();
|
||||
}
|
||||
} catch (MergeIdenticalTreeException | MergeConflictException e) {
|
||||
throw new MergeException("Cherry pick failed: " + e.getMessage());
|
||||
throw new IntegrationException("Cherry pick failed: " + e.getMessage());
|
||||
}
|
||||
} catch (RepositoryNotFoundException e) {
|
||||
throw new NoSuchChangeException(change.getId(), e);
|
||||
|
||||
@@ -34,7 +34,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.inject.Inject;
|
||||
@@ -199,7 +199,7 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
|
||||
|
||||
@Override
|
||||
public Boolean call()
|
||||
throws NoSuchProjectException, MergeException, IOException {
|
||||
throws NoSuchProjectException, IntegrationException, IOException {
|
||||
if (key.into.equals(ObjectId.zeroId())) {
|
||||
return true; // Assume yes on new branch.
|
||||
}
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
|
||||
/** Indicates the current branch's queue cannot be processed at this time. */
|
||||
public class MergeException extends Exception {
|
||||
/** Indicates an integration operation (see {@link MergeOp}) failed. */
|
||||
public class IntegrationException extends Exception {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MergeException(String msg) {
|
||||
public IntegrationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public MergeException(Throwable why) {
|
||||
public IntegrationException(Throwable why) {
|
||||
super(why);
|
||||
}
|
||||
|
||||
public MergeException(String msg, Throwable why) {
|
||||
public IntegrationException(String msg, Throwable why) {
|
||||
super(msg, why);
|
||||
}
|
||||
}
|
||||
@@ -226,10 +226,12 @@ public class MergeOp {
|
||||
mergeTips = new HashMap<>();
|
||||
}
|
||||
|
||||
private void setDestProject(Branch.NameKey destBranch) throws MergeException {
|
||||
private void setDestProject(Branch.NameKey destBranch)
|
||||
throws IntegrationException {
|
||||
destProject = projectCache.get(destBranch.getParentKey());
|
||||
if (destProject == null) {
|
||||
throw new MergeException("No such project: " + destBranch.getParentKey());
|
||||
throw new IntegrationException(
|
||||
"No such project: " + destBranch.getParentKey());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -376,7 +378,7 @@ public class MergeOp {
|
||||
}
|
||||
try {
|
||||
integrateIntoHistory(cs, caller);
|
||||
} catch (MergeException e) {
|
||||
} catch (IntegrationException e) {
|
||||
logError("Merge Conflict", e);
|
||||
throw new ResourceConflictException("Merge Conflict", e);
|
||||
}
|
||||
@@ -387,7 +389,8 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private void integrateIntoHistory(ChangeSet cs, IdentifiedUser caller)
|
||||
throws MergeException, NoSuchChangeException, ResourceConflictException {
|
||||
throws IntegrationException, NoSuchChangeException,
|
||||
ResourceConflictException {
|
||||
logDebug("Beginning merge attempt on {}", cs);
|
||||
Map<Branch.NameKey, ListMultimap<SubmitType, ChangeData>> toSubmit =
|
||||
new HashMap<>();
|
||||
@@ -450,9 +453,9 @@ public class MergeOp {
|
||||
+ "abandoning open changes");
|
||||
abandonAllOpenChanges(noProject.project());
|
||||
} catch (OrmException e) {
|
||||
throw new MergeException("Cannot query the database", e);
|
||||
throw new IntegrationException("Cannot query the database", e);
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot query the database", e);
|
||||
throw new IntegrationException("Cannot query the database", e);
|
||||
} finally {
|
||||
closeRepository();
|
||||
}
|
||||
@@ -460,7 +463,7 @@ public class MergeOp {
|
||||
|
||||
private MergeTip preMerge(SubmitStrategy strategy,
|
||||
List<ChangeData> submitted, CodeReviewCommit branchTip)
|
||||
throws MergeException, OrmException {
|
||||
throws IntegrationException, OrmException {
|
||||
logDebug("Running submit strategy {} for {} commits {}",
|
||||
strategy.getClass().getSimpleName(), submitted.size(), submitted);
|
||||
List<CodeReviewCommit> toMerge = new ArrayList<>(submitted.size());
|
||||
@@ -479,20 +482,20 @@ public class MergeOp {
|
||||
|
||||
private SubmitStrategy createStrategy(Branch.NameKey destBranch,
|
||||
SubmitType submitType, CodeReviewCommit branchTip, IdentifiedUser caller)
|
||||
throws MergeException, NoSuchProjectException {
|
||||
throws IntegrationException, NoSuchProjectException {
|
||||
return submitStrategyFactory.create(submitType, db, repo, rw, inserter,
|
||||
canMergeFlag, getAlreadyAccepted(branchTip), destBranch, caller);
|
||||
}
|
||||
|
||||
private void openRepository(Project.NameKey name)
|
||||
throws MergeException, NoSuchProjectException {
|
||||
throws IntegrationException, NoSuchProjectException {
|
||||
try {
|
||||
repo = repoManager.openRepository(name);
|
||||
} catch (RepositoryNotFoundException notFound) {
|
||||
throw new NoSuchProjectException(name, notFound);
|
||||
} catch (IOException err) {
|
||||
String m = "Error opening repository \"" + name.get() + '"';
|
||||
throw new MergeException(m, err);
|
||||
throw new IntegrationException(m, err);
|
||||
}
|
||||
|
||||
rw = CodeReviewCommit.newRevWalk(repo);
|
||||
@@ -517,7 +520,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private RefUpdate getPendingRefUpdate(Branch.NameKey destBranch)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
|
||||
if (pendingRefUpdates.containsKey(destBranch)) {
|
||||
logDebug("Access cached open branch {}: {}", destBranch.get(),
|
||||
@@ -534,8 +537,8 @@ public class MergeOp {
|
||||
branchTip = null;
|
||||
branchUpdate.setExpectedOldObjectId(ObjectId.zeroId());
|
||||
} else {
|
||||
throw new MergeException("The destination branch " + destBranch.get()
|
||||
+ " does not exist anymore.");
|
||||
throw new IntegrationException("The destination branch "
|
||||
+ destBranch.get() + " does not exist anymore.");
|
||||
}
|
||||
|
||||
logDebug("Opened branch {}: {}", destBranch.get(), branchTip);
|
||||
@@ -543,12 +546,12 @@ public class MergeOp {
|
||||
openBranches.put(destBranch, branchTip);
|
||||
return branchUpdate;
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot open branch", e);
|
||||
throw new IntegrationException("Cannot open branch", e);
|
||||
}
|
||||
}
|
||||
|
||||
private CodeReviewCommit getBranchTip(Branch.NameKey destBranch)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
if (openBranches.containsKey(destBranch)) {
|
||||
return openBranches.get(destBranch);
|
||||
} else {
|
||||
@@ -558,7 +561,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private Set<RevCommit> getAlreadyAccepted(CodeReviewCommit branchTip)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
Set<RevCommit> alreadyAccepted = new HashSet<>();
|
||||
|
||||
if (branchTip != null) {
|
||||
@@ -574,7 +577,7 @@ public class MergeOp {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException(
|
||||
throw new IntegrationException(
|
||||
"Failed to determine already accepted commits.", e);
|
||||
}
|
||||
|
||||
@@ -583,7 +586,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private ListMultimap<SubmitType, ChangeData> validateChangeList(
|
||||
Collection<ChangeData> submitted) throws MergeException {
|
||||
Collection<ChangeData> submitted) throws IntegrationException {
|
||||
logDebug("Validating {} changes", submitted.size());
|
||||
ListMultimap<SubmitType, ChangeData> toSubmit = ArrayListMultimap.create();
|
||||
|
||||
@@ -591,7 +594,7 @@ public class MergeOp {
|
||||
try {
|
||||
allRefs = repo.getRefDatabase().getRefs(ALL);
|
||||
} catch (IOException e) {
|
||||
throw new MergeException(e.getMessage(), e);
|
||||
throw new IntegrationException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
Set<ObjectId> tips = new HashSet<>();
|
||||
@@ -607,7 +610,7 @@ public class MergeOp {
|
||||
// Reload change in case index was stale.
|
||||
chg = cd.reloadChange();
|
||||
} catch (OrmException e) {
|
||||
throw new MergeException("Failed to validate changes", e);
|
||||
throw new IntegrationException("Failed to validate changes", e);
|
||||
}
|
||||
Change.Id changeId = cd.getId();
|
||||
if (chg.getStatus() != Change.Status.NEW) {
|
||||
@@ -625,7 +628,7 @@ public class MergeOp {
|
||||
try {
|
||||
ps = cd.currentPatchSet();
|
||||
} catch (OrmException e) {
|
||||
throw new MergeException("Cannot query the database", e);
|
||||
throw new IntegrationException("Cannot query the database", e);
|
||||
}
|
||||
if (ps == null || ps.getRevision() == null
|
||||
|| ps.getRevision().get() == null) {
|
||||
@@ -718,7 +721,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
private RefUpdate updateBranch(Branch.NameKey destBranch)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
RefUpdate branchUpdate = getPendingRefUpdate(destBranch);
|
||||
CodeReviewCommit branchTip = getBranchTip(destBranch);
|
||||
|
||||
@@ -746,7 +749,7 @@ public class MergeOp {
|
||||
new ProjectConfig(destProject.getProject().getNameKey());
|
||||
cfg.load(repo, currentTip);
|
||||
} catch (Exception e) {
|
||||
throw new MergeException("Submit would store invalid"
|
||||
throw new IntegrationException("Submit would store invalid"
|
||||
+ " project configuration " + currentTip.name() + " for "
|
||||
+ destProject.getProject().getName(), e);
|
||||
}
|
||||
@@ -782,13 +785,13 @@ public class MergeOp {
|
||||
return branchUpdate;
|
||||
|
||||
case LOCK_FAILURE:
|
||||
throw new MergeException("Failed to lock " + branchUpdate.getName());
|
||||
throw new IntegrationException("Failed to lock " + branchUpdate.getName());
|
||||
default:
|
||||
throw new IOException(branchUpdate.getResult().name()
|
||||
+ '\n' + branchUpdate);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot update " + branchUpdate.getName(), e);
|
||||
throw new IntegrationException("Cannot update " + branchUpdate.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +823,7 @@ public class MergeOp {
|
||||
|
||||
private void updateChangeStatus(List<ChangeData> submitted,
|
||||
Branch.NameKey destBranch, boolean dryRun, IdentifiedUser caller)
|
||||
throws NoSuchChangeException, MergeException, ResourceConflictException,
|
||||
throws NoSuchChangeException, IntegrationException, ResourceConflictException,
|
||||
OrmException {
|
||||
if (!dryRun) {
|
||||
logDebug("Updating change status for {} changes", submitted.size());
|
||||
@@ -896,8 +899,8 @@ public class MergeOp {
|
||||
|
||||
case MISSING_DEPENDENCY:
|
||||
logDebug("Change {} is missing dependency", c.getId());
|
||||
throw new MergeException("Cannot merge " + commit.name() + "\n"
|
||||
+ s.getMessage());
|
||||
throw new IntegrationException(
|
||||
"Cannot merge " + commit.name() + "\n" + s.getMessage());
|
||||
|
||||
case REVISION_GONE:
|
||||
logDebug("Commit not found for change {}", c.getId());
|
||||
@@ -910,12 +913,12 @@ public class MergeOp {
|
||||
c.currentPatchSetId());
|
||||
msg.setMessage("Failed to read commit for this patch set");
|
||||
setNew(commit.notes(), msg);
|
||||
throw new MergeException(msg.getMessage());
|
||||
throw new IntegrationException(msg.getMessage());
|
||||
|
||||
default:
|
||||
msg = message(c, "Unspecified merge failure: " + s.name());
|
||||
setNew(commit.notes(), msg);
|
||||
throw new MergeException(msg.getMessage());
|
||||
throw new IntegrationException(msg.getMessage());
|
||||
}
|
||||
} catch (OrmException | IOException err) {
|
||||
logWarn("Error updating change status for " + c.getId(), err);
|
||||
|
||||
@@ -139,7 +139,7 @@ public class MergeUtil {
|
||||
|
||||
public CodeReviewCommit getFirstFastForward(
|
||||
final CodeReviewCommit mergeTip, final RevWalk rw,
|
||||
final List<CodeReviewCommit> toMerge) throws MergeException {
|
||||
final List<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
for (final Iterator<CodeReviewCommit> i = toMerge.iterator(); i.hasNext();) {
|
||||
try {
|
||||
final CodeReviewCommit n = i.next();
|
||||
@@ -148,19 +148,20 @@ public class MergeUtil {
|
||||
return n;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot fast-forward test during merge", e);
|
||||
throw new IntegrationException(
|
||||
"Cannot fast-forward test during merge", e);
|
||||
}
|
||||
}
|
||||
return mergeTip;
|
||||
}
|
||||
|
||||
public List<CodeReviewCommit> reduceToMinimalMerge(MergeSorter mergeSorter,
|
||||
Collection<CodeReviewCommit> toSort) throws MergeException {
|
||||
Collection<CodeReviewCommit> toSort) throws IntegrationException {
|
||||
List<CodeReviewCommit> result = new ArrayList<>();
|
||||
try {
|
||||
result.addAll(mergeSorter.sort(toSort));
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Branch head sorting failed", e);
|
||||
throw new IntegrationException("Branch head sorting failed", e);
|
||||
}
|
||||
Collections.sort(result, CodeReviewCommit.ORDER);
|
||||
return result;
|
||||
@@ -346,7 +347,7 @@ public class MergeUtil {
|
||||
public boolean canMerge(final MergeSorter mergeSorter,
|
||||
final Repository repo, final CodeReviewCommit mergeTip,
|
||||
final CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
if (hasMissingDependencies(mergeSorter, toMerge)) {
|
||||
return false;
|
||||
}
|
||||
@@ -360,13 +361,13 @@ public class MergeUtil {
|
||||
} catch (NoMergeBaseException e) {
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot merge " + toMerge.name(), e);
|
||||
throw new IntegrationException("Cannot merge " + toMerge.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canFastForward(MergeSorter mergeSorter,
|
||||
CodeReviewCommit mergeTip, CodeReviewRevWalk rw, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
if (hasMissingDependencies(mergeSorter, toMerge)) {
|
||||
return false;
|
||||
}
|
||||
@@ -374,13 +375,13 @@ public class MergeUtil {
|
||||
try {
|
||||
return mergeTip == null || rw.isMergedInto(mergeTip, toMerge);
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot fast-forward test during merge", e);
|
||||
throw new IntegrationException("Cannot fast-forward test during merge", e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canCherryPick(MergeSorter mergeSorter, Repository repo,
|
||||
CodeReviewCommit mergeTip, CodeReviewRevWalk rw, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
if (mergeTip == null) {
|
||||
// The branch is unborn. Fast-forward is possible.
|
||||
//
|
||||
@@ -404,7 +405,7 @@ public class MergeUtil {
|
||||
m.setBase(toMerge.getParent(0));
|
||||
return m.merge(mergeTip, toMerge);
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot merge " + toMerge.name(), e);
|
||||
throw new IntegrationException("Cannot merge " + toMerge.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,11 +420,11 @@ public class MergeUtil {
|
||||
}
|
||||
|
||||
public boolean hasMissingDependencies(final MergeSorter mergeSorter,
|
||||
final CodeReviewCommit toMerge) throws MergeException {
|
||||
final CodeReviewCommit toMerge) throws IntegrationException {
|
||||
try {
|
||||
return !mergeSorter.sort(Collections.singleton(toMerge)).contains(toMerge);
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Branch head sorting failed", e);
|
||||
throw new IntegrationException("Branch head sorting failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,7 +451,8 @@ public class MergeUtil {
|
||||
public CodeReviewCommit mergeOneCommit(PersonIdent author,
|
||||
PersonIdent committer, Repository repo, CodeReviewRevWalk rw,
|
||||
ObjectInserter inserter, RevFlag canMergeFlag, Branch.NameKey destBranch,
|
||||
CodeReviewCommit mergeTip, CodeReviewCommit n) throws MergeException {
|
||||
CodeReviewCommit mergeTip, CodeReviewCommit n)
|
||||
throws IntegrationException {
|
||||
final ThreeWayMerger m = newThreeWayMerger(repo, inserter);
|
||||
try {
|
||||
if (m.merge(new AnyObjectId[] {mergeTip, n})) {
|
||||
@@ -464,10 +466,10 @@ public class MergeUtil {
|
||||
failed(rw, canMergeFlag, mergeTip, n,
|
||||
getCommitMergeStatus(e.getReason()));
|
||||
} catch (IOException e2) {
|
||||
throw new MergeException("Cannot merge " + n.name(), e);
|
||||
throw new IntegrationException("Cannot merge " + n.name(), e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot merge " + n.name(), e);
|
||||
throw new IntegrationException("Cannot merge " + n.name(), e);
|
||||
}
|
||||
return mergeTip;
|
||||
}
|
||||
@@ -640,7 +642,7 @@ public class MergeUtil {
|
||||
|
||||
public void markCleanMerges(final RevWalk rw,
|
||||
final RevFlag canMergeFlag, final CodeReviewCommit mergeTip,
|
||||
final Set<RevCommit> alreadyAccepted) throws MergeException {
|
||||
final Set<RevCommit> alreadyAccepted) throws IntegrationException {
|
||||
if (mergeTip == null) {
|
||||
// If mergeTip is null here, branchTip was null, indicating a new branch
|
||||
// at the start of the merge process. We also elected to merge nothing,
|
||||
@@ -665,7 +667,7 @@ public class MergeUtil {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot mark clean merges", e);
|
||||
throw new IntegrationException("Cannot mark clean merges", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ 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.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeIdenticalTreeException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
import com.google.gerrit.server.git.UpdateException;
|
||||
@@ -62,7 +62,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
protected MergeTip _run(CodeReviewCommit branchTip,
|
||||
Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
MergeTip mergeTip = new MergeTip(branchTip, toMerge);
|
||||
List<CodeReviewCommit> sorted = CodeReviewCommit.ORDER.sortedCopy(toMerge);
|
||||
boolean first = true;
|
||||
@@ -83,7 +83,8 @@ public class CherryPick extends SubmitStrategy {
|
||||
}
|
||||
u.execute();
|
||||
} catch (UpdateException | RestApiException e) {
|
||||
throw new MergeException("Cannot cherry-pick onto " + args.destBranch);
|
||||
throw new IntegrationException(
|
||||
"Cannot cherry-pick onto " + args.destBranch);
|
||||
}
|
||||
// TODO(dborowitz): When BatchUpdate is hoisted out of CherryPick,
|
||||
// SubmitStrategy should probably no longer return MergeTip, instead just
|
||||
@@ -214,7 +215,8 @@ public class CherryPick extends SubmitStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx) throws MergeException, IOException {
|
||||
public void updateRepo(RepoContext ctx)
|
||||
throws IntegrationException, IOException {
|
||||
if (args.mergeUtil.hasMissingDependencies(args.mergeSorter, toMerge)) {
|
||||
// One or more dependencies were not met. The status was already marked
|
||||
// on the commit so we have nothing further to perform at this time.
|
||||
@@ -249,7 +251,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
public boolean dryRun(CodeReviewCommit mergeTip, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
return args.mergeUtil.canCherryPick(args.mergeSorter, args.repo,
|
||||
mergeTip, args.rw, toMerge);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CommitMergeStatus;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -29,7 +29,7 @@ public class FastForwardOnly extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
protected MergeTip _run(final CodeReviewCommit branchTip,
|
||||
final Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
final Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
MergeTip mergeTip = new MergeTip(branchTip, toMerge);
|
||||
List<CodeReviewCommit> sorted = args.mergeUtil.reduceToMinimalMerge(
|
||||
args.mergeSorter, toMerge);
|
||||
@@ -56,7 +56,7 @@ public class FastForwardOnly extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
public boolean dryRun(CodeReviewCommit mergeTip,
|
||||
CodeReviewCommit toMerge) throws MergeException {
|
||||
CodeReviewCommit toMerge) throws IntegrationException {
|
||||
return args.mergeUtil.canFastForward(args.mergeSorter, mergeTip, args.rw,
|
||||
toMerge);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
@@ -30,7 +30,7 @@ public class MergeAlways extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
protected MergeTip _run(CodeReviewCommit branchTip,
|
||||
Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
List<CodeReviewCommit> sorted = args.mergeUtil.reduceToMinimalMerge(args.mergeSorter, toMerge);
|
||||
MergeTip mergeTip;
|
||||
if (branchTip == null) {
|
||||
@@ -62,7 +62,7 @@ public class MergeAlways extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
public boolean dryRun(CodeReviewCommit mergeTip, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
return args.mergeUtil.canMerge(args.mergeSorter, args.repo, mergeTip,
|
||||
toMerge);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
@@ -30,7 +30,7 @@ public class MergeIfNecessary extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
protected MergeTip _run(CodeReviewCommit branchTip,
|
||||
Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
List<CodeReviewCommit> sorted =
|
||||
args.mergeUtil.reduceToMinimalMerge(args.mergeSorter, toMerge);
|
||||
MergeTip mergeTip;
|
||||
@@ -67,7 +67,7 @@ public class MergeIfNecessary extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
public boolean dryRun(CodeReviewCommit mergeTip, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
return args.mergeUtil.canFastForward(
|
||||
args.mergeSorter, mergeTip, args.rw, toMerge)
|
||||
|| args.mergeUtil.canMerge(
|
||||
|
||||
@@ -25,7 +25,7 @@ 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.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
import com.google.gerrit.server.git.RebaseSorter;
|
||||
import com.google.gerrit.server.git.UpdateException;
|
||||
@@ -60,7 +60,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
protected MergeTip _run(final CodeReviewCommit branchTip,
|
||||
final Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
final Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
MergeTip mergeTip = new MergeTip(branchTip, toMerge);
|
||||
List<CodeReviewCommit> sorted = sort(toMerge);
|
||||
while (!sorted.isEmpty()) {
|
||||
@@ -113,11 +113,11 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
setRefLogIdent();
|
||||
} catch (MergeConflictException e) {
|
||||
n.setStatusCode(CommitMergeStatus.REBASE_MERGE_CONFLICT);
|
||||
throw new MergeException(
|
||||
throw new IntegrationException(
|
||||
"Cannot rebase " + n.name() + ": " + e.getMessage(), e);
|
||||
} catch (NoSuchChangeException | OrmException | IOException
|
||||
| RestApiException | UpdateException e) {
|
||||
throw new MergeException("Cannot rebase " + n.name(), e);
|
||||
throw new IntegrationException("Cannot rebase " + n.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
mergeTip.getCurrentTip(), args.alreadyAccepted);
|
||||
setRefLogIdent();
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Cannot merge " + n.name(), e);
|
||||
throw new IntegrationException("Cannot merge " + n.name(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,14 +153,14 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
}
|
||||
|
||||
private List<CodeReviewCommit> sort(Collection<CodeReviewCommit> toSort)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
try {
|
||||
List<CodeReviewCommit> result = new RebaseSorter(
|
||||
args.rw, args.alreadyAccepted, args.canMergeFlag).sort(toSort);
|
||||
Collections.sort(result, CodeReviewCommit.ORDER);
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
throw new MergeException("Commit sorting failed", e);
|
||||
throw new IntegrationException("Commit sorting failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
|
||||
@Override
|
||||
public boolean dryRun(CodeReviewCommit mergeTip, CodeReviewCommit toMerge)
|
||||
throws MergeException {
|
||||
throws IntegrationException {
|
||||
return !args.mergeUtil.hasMissingDependencies(args.mergeSorter, toMerge)
|
||||
&& args.mergeUtil.canCherryPick(args.mergeSorter, args.repo, mergeTip,
|
||||
args.rw, toMerge);
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.git.BatchUpdate;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeSorter;
|
||||
import com.google.gerrit.server.git.MergeTip;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
@@ -124,10 +124,10 @@ public abstract class SubmitStrategy {
|
||||
* this submit strategy. Implementations are responsible for ordering
|
||||
* of commits, and should not modify the input in place.
|
||||
* @return the new merge tip.
|
||||
* @throws MergeException
|
||||
* @throws IntegrationException
|
||||
*/
|
||||
public final MergeTip run(final CodeReviewCommit currentTip,
|
||||
final Collection<CodeReviewCommit> toMerge) throws MergeException {
|
||||
final Collection<CodeReviewCommit> toMerge) throws IntegrationException {
|
||||
refLogIdent = null;
|
||||
checkState(args.caller != null);
|
||||
return _run(currentTip, toMerge);
|
||||
@@ -135,7 +135,7 @@ public abstract class SubmitStrategy {
|
||||
|
||||
/** @see #run(CodeReviewCommit, Collection) */
|
||||
protected abstract MergeTip _run(CodeReviewCommit currentTip,
|
||||
Collection<CodeReviewCommit> toMerge) throws MergeException;
|
||||
Collection<CodeReviewCommit> toMerge) throws IntegrationException;
|
||||
|
||||
/**
|
||||
* Checks whether the given commit can be merged.
|
||||
@@ -147,10 +147,10 @@ public abstract class SubmitStrategy {
|
||||
* @param toMerge the commit that should be checked.
|
||||
* @return {@code true} if the given commit can be merged, otherwise
|
||||
* {@code false}
|
||||
* @throws MergeException
|
||||
* @throws IntegrationException
|
||||
*/
|
||||
public abstract boolean dryRun(CodeReviewCommit mergeTip,
|
||||
CodeReviewCommit toMerge) throws MergeException;
|
||||
CodeReviewCommit toMerge) throws IntegrationException;
|
||||
|
||||
/**
|
||||
* Returns the identity that should be used for reflog entries when updating
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.change.RebaseChangeOp;
|
||||
import com.google.gerrit.server.git.BatchUpdate;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
@@ -90,7 +90,7 @@ public class SubmitStrategyFactory {
|
||||
Repository repo, CodeReviewRevWalk rw, ObjectInserter inserter,
|
||||
RevFlag canMergeFlag, Set<RevCommit> alreadyAccepted,
|
||||
Branch.NameKey destBranch, IdentifiedUser caller)
|
||||
throws MergeException, NoSuchProjectException {
|
||||
throws IntegrationException, NoSuchProjectException {
|
||||
ProjectState project = getProject(destBranch);
|
||||
SubmitStrategy.Arguments args = new SubmitStrategy.Arguments(
|
||||
identifiedUserFactory, myIdent, db, batchUpdateFactory,
|
||||
@@ -111,7 +111,7 @@ public class SubmitStrategyFactory {
|
||||
default:
|
||||
final String errorMsg = "No submit strategy for: " + submitType;
|
||||
log.error(errorMsg);
|
||||
throw new MergeException(errorMsg);
|
||||
throw new IntegrationException(errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit.CodeReviewRevWalk;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.IntegrationException;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategy;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
@@ -129,7 +129,8 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
||||
conflicts = !strategy.dryRun(commit, otherCommit);
|
||||
args.conflictsCache.put(conflictsKey, conflicts);
|
||||
return conflicts;
|
||||
} catch (MergeException | NoSuchProjectException | IOException e) {
|
||||
} catch (IntegrationException | NoSuchProjectException
|
||||
| IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
@@ -148,7 +149,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
||||
}
|
||||
|
||||
private Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw,
|
||||
CodeReviewCommit tip) throws MergeException {
|
||||
CodeReviewCommit tip) throws IntegrationException {
|
||||
Set<RevCommit> alreadyAccepted = Sets.newHashSet();
|
||||
|
||||
if (tip != null) {
|
||||
@@ -164,7 +165,7 @@ class ConflictsPredicate extends OrPredicate<ChangeData> {
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MergeException(
|
||||
throw new IntegrationException(
|
||||
"Failed to determine already accepted commits.", e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user