From 35ced0a374aa2a5d489e0329e7e803a9990a8497 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 27 Jun 2012 19:20:34 -0400 Subject: [PATCH] Also check if user can upload in order to restore The thought behind this is that a restoration is an upload, and the workaround for not restoring would be to make a fresh upload (which we don't want). The main use case is the scenario in which a branch has been closed to further improvements and changes shouldn't be restored. Rather than introduce a new permission for this, keep the abandon conditions so someone can undo an accidental abandon. Change-Id: I31fa95c1325ac932f1fc2c90abf3a5a42c1b24db --- Documentation/access-control.txt | 3 +++ .../java/com/google/gerrit/server/project/ChangeControl.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/access-control.txt b/Documentation/access-control.txt index 23f6e72b98..7027562384 100644 --- a/Documentation/access-control.txt +++ b/Documentation/access-control.txt @@ -452,6 +452,9 @@ This category controls whether users are allowed to abandon changes to projects in Gerrit. It can give permission to abandon a specific change to a given ref. +This also grants the permission to restore a change if the change +can be uploaded. + [[category_create]] Create reference ~~~~~~~~~~~~~~~~ diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java index 7387fd1b1c..41f2aa684b 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java @@ -211,7 +211,8 @@ public class ChangeControl { /** Can this user restore this change? */ public boolean canRestore() { - return canAbandon(); // Anyone who can abandon the change can restore it back + return canAbandon() // Anyone who can abandon the change can restore it back + && getRefControl().canUpload(); // as long as you can upload too } /** All value ranges of any allowed label permission. */