Change: Add helper methods to check change state

To check a change's state the caller currently has to call getState()
and then do a comparison on the enum value.

To make this easier, introduce new methods on Change:

- isNew
- isMerged
- isAbandoned
- isClosed

Note that we don't add "isOpen" since there are no longer multiple
states that could be considered "open". Previously there were "new"
and "draft", but the draft workflow was removed.

Update callers to use the new methods.

Change-Id: Ic047f74b114e2277e66c878dace73ea8e0babab6
This commit is contained in:
David Pursehouse
2019-02-14 13:15:41 +09:00
parent f23f78c99f
commit 4c58e1031f
48 changed files with 114 additions and 117 deletions

View File

@@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkState;
import com.google.gerrit.extensions.restapi.MergeConflictException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.server.ChangeUtil;
@@ -194,8 +193,8 @@ public class RebaseChangeOp implements BatchUpdateOp {
+ " was rebased");
}
if (base != null && base.notes().getChange().getStatus() != Change.Status.MERGED) {
if (base.notes().getChange().getStatus() != Change.Status.MERGED) {
if (base != null && !base.notes().getChange().isMerged()) {
if (!base.notes().getChange().isMerged()) {
// Add to end of relation chain for open base change.
patchSetInserter.setGroups(base.patchSet().getGroups());
} else {