Support branch specific labels

By default a given project's label applicable scope is all changes
on all branches of this project and its child projects.

Label's applicable scope can be branch specific via configuration.
E.g. create a label 'Video-Qualify' on parent project and configure
the 'branch' as:

[label "Video-Qualify"]
    branch = refs/heads/video-1.0/*
    branch = refs/heads/video-1.1/Kino

Then ONLY changes in above branch scope of parent project and child
projects will be affected by 'Video-Qualify'.

Please note the 'branch' is independent from the branch scope related
to access control defined in 'access' parts in 'project.config' file.
That means from the UI a user can always assign permissions for that
label on a branch, but this permission is then ignored if the label
doesn't apply for that branch.

Change-Id: I414e62503b0da4af022abbc9988593ba9ac87916
This commit is contained in:
Bruce Zu
2013-09-06 01:23:03 +08:00
parent 9aaf3d15e3
commit 9b22c3ab2d
5 changed files with 73 additions and 12 deletions

View File

@@ -16,9 +16,7 @@ package gerrit;
import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelValue;
import com.google.gerrit.rules.PrologEnvironment;
import com.google.gerrit.rules.StoredValues;
import com.google.gerrit.server.project.ProjectState;
import com.googlecode.prolog_cafe.lang.IntegerTerm;
import com.googlecode.prolog_cafe.lang.ListTerm;
@@ -55,14 +53,8 @@ class PRED_get_legacy_label_types_1 extends Predicate.P1 {
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
PrologEnvironment env = (PrologEnvironment) engine.control;
ProjectState state = env.getArgs().getProjectCache()
.get(StoredValues.CHANGE.get(engine).getDest().getParentKey());
if (state == null) {
return engine.fail();
}
List<LabelType> list = state.getLabelTypes().getLabelTypes();
List<LabelType> list =
StoredValues.CHANGE_CONTROL.get(engine).getLabelTypes().getLabelTypes();
Term head = Prolog.Nil;
for (int idx = list.size() - 1; 0 <= idx; idx--) {
head = new ListTerm(export(list.get(idx)), head);