diff --git a/gerrit-server/src/main/java/com/google/gerrit/rules/StoredValues.java b/gerrit-server/src/main/java/com/google/gerrit/rules/StoredValues.java index eb4665fd12..89feddae6f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/rules/StoredValues.java +++ b/gerrit-server/src/main/java/com/google/gerrit/rules/StoredValues.java @@ -37,7 +37,7 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException; import com.google.gerrit.server.patch.PatchSetInfoFactory; import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException; import com.google.gerrit.server.permissions.PermissionBackend; -import com.google.gerrit.server.project.ChangeControl; +import com.google.gerrit.server.project.ProjectState; import com.google.gerrit.server.query.change.ChangeData; import com.google.gwtorm.server.OrmException; import com.googlecode.prolog_cafe.exceptions.SystemException; @@ -54,13 +54,8 @@ public final class StoredValues { public static final StoredValue EMAILS = create(Emails.class); public static final StoredValue REVIEW_DB = create(ReviewDb.class); public static final StoredValue CHANGE_DATA = create(ChangeData.class); - - // Note: no guarantees are made about the user passed in the ChangeControl; do - // not depend on this directly. Either use .forUser(otherUser) to get a - // control for a specific known user, or use CURRENT_USER, which may be null - // for rule types that may not depend on the current user. - public static final StoredValue CHANGE_CONTROL = create(ChangeControl.class); public static final StoredValue CURRENT_USER = create(CurrentUser.class); + public static final StoredValue PROJECT_STATE = create(ProjectState.class); public static Change getChange(Prolog engine) throws SystemException { ChangeData cd = CHANGE_DATA.get(engine); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java index 4595933dcb..5ab629a2e4 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/SubmitRuleEvaluator.java @@ -580,10 +580,10 @@ public class SubmitRuleEvaluator { env.set(StoredValues.EMAILS, emails); env.set(StoredValues.REVIEW_DB, cd.db()); env.set(StoredValues.CHANGE_DATA, cd); - env.set(StoredValues.CHANGE_CONTROL, control); if (user != null) { env.set(StoredValues.CURRENT_USER, user); } + env.set(StoredValues.PROJECT_STATE, projectState); return env; } diff --git a/gerrit-server/src/main/java/gerrit/PRED_project_default_submit_type_1.java b/gerrit-server/src/main/java/gerrit/PRED_project_default_submit_type_1.java index cedad9e251..1d9643346c 100644 --- a/gerrit-server/src/main/java/gerrit/PRED_project_default_submit_type_1.java +++ b/gerrit-server/src/main/java/gerrit/PRED_project_default_submit_type_1.java @@ -16,7 +16,7 @@ package gerrit; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.rules.StoredValues; -import com.google.gerrit.server.project.ChangeControl; +import com.google.gerrit.server.project.ProjectState; import com.googlecode.prolog_cafe.exceptions.PrologException; import com.googlecode.prolog_cafe.lang.Operation; import com.googlecode.prolog_cafe.lang.Predicate; @@ -46,9 +46,8 @@ public class PRED_project_default_submit_type_1 extends Predicate.P1 { engine.setB0(); Term a1 = arg1.dereference(); - ChangeControl control = StoredValues.CHANGE_CONTROL.get(engine); - SubmitType submitType = control.getProject().getSubmitType(); - + ProjectState projectState = StoredValues.PROJECT_STATE.get(engine); + SubmitType submitType = projectState.getProject().getSubmitType(); if (!a1.unify(term[submitType.ordinal()], engine.trail)) { return engine.fail(); }