Merge "Handle error when publishing non draft patch set"

This commit is contained in:
Edwin Kempin
2012-02-08 23:28:59 -08:00
committed by gerrit code review
3 changed files with 13 additions and 2 deletions

View File

@@ -67,7 +67,10 @@ public class ReviewResult {
PUBLISH_NOT_PERMITTED, PUBLISH_NOT_PERMITTED,
/** Review operation not permitted by rule. */ /** Review operation not permitted by rule. */
RULE_ERROR RULE_ERROR,
/** Review operation invalid because patch set is not a draft. */
NOT_A_DRAFT,
} }
protected Type type; protected Type type;

View File

@@ -57,9 +57,14 @@ public class PublishDraft implements Callable<ReviewResult> {
result.setChangeId(changeId); result.setChangeId(changeId);
final ChangeControl control = changeControlFactory.validateFor(changeId); final ChangeControl control = changeControlFactory.validateFor(changeId);
final PatchSet patch = db.patchSets().get(patchSetId); final PatchSet patch = db.patchSets().get(patchSetId);
if (patch == null || !patch.isDraft()) { if (patch == null) {
throw new NoSuchChangeException(changeId); throw new NoSuchChangeException(changeId);
} }
if (!patch.isDraft()) {
result.addError(new ReviewResult.Error(
ReviewResult.Error.Type.NOT_A_DRAFT));
return result;
}
if (!control.canPublish(db)) { if (!control.canPublish(db)) {
result.addError(new ReviewResult.Error( result.addError(new ReviewResult.Error(

View File

@@ -294,6 +294,9 @@ public class ReviewCommand extends BaseCommand {
case RULE_ERROR: case RULE_ERROR:
errMsg += "rule error"; errMsg += "rule error";
break; break;
case NOT_A_DRAFT:
errMsg += "change is not a draft";
break;
default: default:
errMsg += "failure in review"; errMsg += "failure in review";
} }