use of com.google.gerrit.server.git.CodeReviewCommit in project gerrit by GerritCodeReview.
the class SubmitStrategyListener method checkCommitStatus.
private List<Change.Id> checkCommitStatus() throws ResourceConflictException {
List<Change.Id> alreadyMerged = new ArrayList<>(commitStatus.getChangeIds().size());
for (Change.Id id : commitStatus.getChangeIds()) {
CodeReviewCommit commit = commitStatus.get(id);
CommitMergeStatus s = commit != null ? commit.getStatusCode() : null;
if (s == null) {
commitStatus.problem(id, "internal error: change not processed by merge strategy");
continue;
}
switch(s) {
case CLEAN_MERGE:
case CLEAN_REBASE:
case CLEAN_PICK:
case SKIPPED_IDENTICAL_TREE:
// Merge strategy accepted this change.
break;
case ALREADY_MERGED:
// Already an ancestor of tip.
alreadyMerged.add(commit.getPatchsetId().getParentKey());
break;
case PATH_CONFLICT:
case REBASE_MERGE_CONFLICT:
case MANUAL_RECURSIVE_MERGE:
case CANNOT_CHERRY_PICK_ROOT:
case CANNOT_REBASE_ROOT:
case NOT_FAST_FORWARD:
// TODO(dborowitz): Reformat these messages to be more appropriate for
// short problem descriptions.
commitStatus.problem(id, CharMatcher.is('\n').collapseFrom(s.getMessage(), ' '));
break;
case MISSING_DEPENDENCY:
commitStatus.problem(id, "depends on change that was not submitted");
break;
default:
commitStatus.problem(id, "unspecified merge failure: " + s);
break;
}
}
commitStatus.maybeFailVerbose();
return alreadyMerged;
}
use of com.google.gerrit.server.git.CodeReviewCommit in project gerrit by GerritCodeReview.
the class CherryPick method buildOps.
@Override
public List<SubmitStrategyOp> buildOps(Collection<CodeReviewCommit> toMerge) throws IntegrationException {
List<CodeReviewCommit> sorted = CodeReviewCommit.ORDER.sortedCopy(toMerge);
List<SubmitStrategyOp> ops = new ArrayList<>(sorted.size());
boolean first = true;
while (!sorted.isEmpty()) {
CodeReviewCommit n = sorted.remove(0);
if (first && args.mergeTip.getInitialTip() == null) {
ops.add(new FastForwardOp(args, n));
} else if (n.getParentCount() == 0) {
ops.add(new CherryPickRootOp(n));
} else if (n.getParentCount() == 1) {
ops.add(new CherryPickOneOp(n));
} else {
ops.add(new CherryPickMultipleParentsOp(n));
}
first = false;
}
return ops;
}
use of com.google.gerrit.server.git.CodeReviewCommit in project gerrit by GerritCodeReview.
the class MergeOneOp method updateRepoImpl.
@Override
public void updateRepoImpl(RepoContext ctx) throws IntegrationException, IOException {
PersonIdent caller = ctx.getIdentifiedUser().newCommitterIdent(ctx.getWhen(), ctx.getTimeZone());
if (args.mergeTip.getCurrentTip() == null) {
throw new IllegalStateException("cannot merge commit " + toMerge.name() + " onto a null tip; expected at least one fast-forward prior to" + " this operation");
}
CodeReviewCommit merged = args.mergeUtil.mergeOneCommit(caller, args.serverIdent, args.rw, ctx.getInserter(), ctx.getRepoView().getConfig(), args.destBranch, args.mergeTip.getCurrentTip(), toMerge);
args.mergeTip.moveTipTo(amendGitlink(merged), toMerge);
}
Aggregations