Merge "Fail review command for changing labels when change is closed"

This commit is contained in:
Shawn Pearce
2011-06-21 12:57:09 -07:00
committed by Android Code Review
2 changed files with 7 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.mail.CommentSender;
import com.google.gerrit.server.mail.EmailException;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.workflow.FunctionState;
import com.google.gwtjsonrpc.client.VoidResult;
@@ -104,7 +105,8 @@ public class PublishComments implements Callable<VoidResult> {
}
@Override
public VoidResult call() throws NoSuchChangeException, OrmException {
public VoidResult call() throws NoSuchChangeException,
InvalidChangeOperationException, OrmException {
final Change.Id changeId = patchSetId.getParentKey();
final ChangeControl ctl = changeControlFactory.validateFor(changeId);
change = ctl.getChange();
@@ -119,6 +121,8 @@ public class PublishComments implements Callable<VoidResult> {
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
if (isCurrent && change.getStatus().isOpen()) {
publishApprovals();
} else if (! approvals.isEmpty()) {
throw new InvalidChangeOperationException("Change is closed");
} else {
publishMessageOnly();
}

View File

@@ -222,9 +222,9 @@ public class ReviewCommand extends BaseCommand {
}
}
try {
publishCommentsFactory.create(patchSetId, changeComment, aps).call();
try {
if (abandonChange) {
if (changeControl.canAbandon()) {
ChangeUtil.abandon(patchSetId, currentUser, changeComment, db,