Remove workflow package and replace with simple LabelNormalizer
The per-CategoryFunction logic has been replaced by Prolog rules, and the only remaining functionality of FunctionState was to normalize labels to the correct ranges. Add a LabelNormalizer that explicitly just normalizes labels, and remove the now-unused classes. In addition to squashing ranges, LabelNormalizer now also removes PatchSetApprovals from the input list that correspond to nonexistent labels. Fix MergeOp to handle this behavior, which can happen for example if a label is removed from the project config while in review. Change-Id: I6955594f7ac1c4e080f82d10f4b2579c31057512
This commit is contained in:
@@ -28,10 +28,9 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gerrit.server.git.LabelNormalizer;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.workflow.CategoryFunction;
|
||||
import com.google.gerrit.server.workflow.FunctionState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -43,15 +42,15 @@ import java.util.TreeMap;
|
||||
|
||||
public class ReviewerJson {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final FunctionState.Factory functionState;
|
||||
private final LabelNormalizer labelNormalizer;
|
||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||
|
||||
@Inject
|
||||
ReviewerJson(Provider<ReviewDb> db,
|
||||
FunctionState.Factory functionState,
|
||||
LabelNormalizer labelNormalizer,
|
||||
AccountInfo.Loader.Factory accountLoaderFactory) {
|
||||
this.db = db;
|
||||
this.functionState = functionState;
|
||||
this.labelNormalizer = labelNormalizer;
|
||||
this.accountLoaderFactory = accountLoaderFactory;
|
||||
}
|
||||
|
||||
@@ -80,12 +79,8 @@ public class ReviewerJson {
|
||||
approvals = ChangeData.sortApprovals(db.get().patchSetApprovals()
|
||||
.byPatchSetUser(psId, out._id));
|
||||
}
|
||||
|
||||
approvals = labelNormalizer.normalize(ctl, approvals);
|
||||
LabelTypes labelTypes = ctl.getLabelTypes();
|
||||
FunctionState fs = functionState.create(ctl, psId, approvals);
|
||||
for (LabelType at : labelTypes.getLabelTypes()) {
|
||||
CategoryFunction.forType(at).run(at, fs);
|
||||
}
|
||||
|
||||
// Don't use Maps.newTreeMap(Comparator) due to OpenJDK bug 100167.
|
||||
out.approvals = new TreeMap<String,String>(labelTypes.nameComparator());
|
||||
|
Reference in New Issue
Block a user