summaryrefslogtreecommitdiffstats
path: root/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
diff options
context:
space:
mode:
authorIsmo Haataja <ismo.haataja@digia.com>2013-04-30 15:14:54 +0300
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-04-27 17:57:36 +0200
commit92ae224f7f21e543397c7e880a9ea3f6536cb68c (patch)
tree57c0bc70dd4579de9667c801c5cf3f4e7443a3c8 /gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
parent2e4ccb61957e8c485091503fd4e944bd9f5002a4 (diff)
Add new change state "deferred".
Support for new change state "deferred" to be able to discern "really dead" from "postponed" changes. This is equal to "abandoned" for all practical purposes except presentation and filtering. State transitions are possible between "review in progress", "abandoned" and "deferred". And menu bar has new "All/deferred" and "My/Deferred Changes" default filters. ============= initial feedback from dave borowitz was slightly negative, the alternative suggestion being to leave the state machine alone and instead use a custom label to mark the deferred changes. in principle i agree, as long as the visible workflow is not affected. otoh, one can do a reductio ad absurdum on the argument ... e.g., why are MERGED and ABANDONED separate states? technically, they are both just CLOSED, with additional label "integrated". ============= Task-number: QTQAINFRA-598 Change-Id: Ib1801f35eabf6b3b32bf41b0f3b5b496fbcda72a Reviewed-by: Ismo Haataja <ismo.haataja@digia.com>
Diffstat (limited to 'gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java')
-rw-r--r--gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java48
1 files changed, 44 insertions, 4 deletions
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
index b48885fccc..a26dfd7259 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
@@ -32,6 +32,7 @@ import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.change.Abandon;
import com.google.gerrit.server.change.ChangeResource;
+import com.google.gerrit.server.change.Defer;
import com.google.gerrit.server.change.PostReview;
import com.google.gerrit.server.change.Restore;
import com.google.gerrit.server.change.RevisionResource;
@@ -101,7 +102,10 @@ public class ReviewCommand extends SshCommand {
@Option(name = "--abandon", usage = "abandon the specified change(s)")
private boolean abandonChange;
- @Option(name = "--restore", usage = "restore the specified abandoned change(s)")
+ @Option(name = "--defer", usage = "defer the specified change(s)")
+ private boolean deferChange;
+
+ @Option(name = "--restore", usage = "restore the specified abandoned or deferred change(s)")
private boolean restoreChange;
@Option(name = "--submit", aliases = "-s", usage = "submit the specified patch set(s)")
@@ -155,6 +159,9 @@ public class ReviewCommand extends SshCommand {
private Provider<Abandon> abandonProvider;
@Inject
+ private Provider<Defer> deferProvider;
+
+ @Inject
private Provider<PostReview> reviewProvider;
@Inject
@@ -181,6 +188,9 @@ public class ReviewCommand extends SshCommand {
if (submitChange) {
throw error("abandon and submit actions are mutually exclusive");
}
+ if (deferChange) {
+ throw error("abandon and defer actions are mutually exclusive");
+ }
if (publishPatchSet) {
throw error("abandon and publish actions are mutually exclusive");
}
@@ -191,6 +201,20 @@ public class ReviewCommand extends SshCommand {
throw error("abandon and stage actions are mutually exclusive");
}
}
+ if (deferChange) {
+ if (restoreChange) {
+ throw error("defer and restore actions are mutually exclusive");
+ }
+ if (submitChange) {
+ throw error("defer and submit actions are mutually exclusive");
+ }
+ if (publishPatchSet) {
+ throw error("defer and publish actions are mutually exclusive");
+ }
+ if (deleteDraftPatchSet) {
+ throw error("defer and delete actions are mutually exclusive");
+ }
+ }
if (publishPatchSet) {
if (restoreChange) {
throw error("publish and restore actions are mutually exclusive");
@@ -261,9 +285,9 @@ public class ReviewCommand extends SshCommand {
review.labels.putAll(customLabels);
// If review labels are being applied, the comment will be included
- // on the review note. We don't need to add it again on the abandon
- // or restore comment.
- if (!review.labels.isEmpty() && (abandonChange || restoreChange)) {
+ // on the review note. We don't need to add it again on the abandon,
+ // defer or restore comment.
+ if (!review.labels.isEmpty() && (abandonChange || deferChange || restoreChange)) {
changeComment = null;
}
@@ -284,6 +308,18 @@ public class ReviewCommand extends SshCommand {
} catch (ResourceConflictException e) {
writeError("error: " + parseError(Type.CHANGE_IS_CLOSED) + "\n");
}
+ } else if (deferChange) {
+ final Defer defer = deferProvider.get();
+ final Defer.Input input = new Defer.Input();
+ input.message = changeComment;
+ applyReview(ctl, patchSet, review);
+ try {
+ defer.apply(new ChangeResource(ctl), input);
+ } catch (AuthException e) {
+ writeError("error: " + parseError(Type.DEFER_NOT_PERMITTED) + "\n");
+ } catch (ResourceConflictException e) {
+ writeError("error: " + parseError(Type.CHANGE_IS_CLOSED) + "\n");
+ }
} else if (restoreChange) {
final Restore restore = restoreProvider.get();
final Restore.Input input = new Restore.Input();
@@ -354,6 +390,8 @@ public class ReviewCommand extends SshCommand {
switch (type) {
case ABANDON_NOT_PERMITTED:
return "not permitted to abandon change";
+ case DEFER_NOT_PERMITTED:
+ return "not permitted to defer change";
case RESTORE_NOT_PERMITTED:
return "not permitted to restore change";
case SUBMIT_NOT_PERMITTED:
@@ -364,6 +402,8 @@ public class ReviewCommand extends SshCommand {
return "change is closed";
case CHANGE_NOT_ABANDONED:
return "change is not abandoned";
+ case CHANGE_NOT_DEFERRED:
+ return "change is not deferred";
case PUBLISH_NOT_PERMITTED:
return "not permitted to publish change";
case DELETE_NOT_PERMITTED: