Allow parent projects to block children from overriding labels

A label section with "canOverride = false" means attempting to
override this label in a child project is a no-op.

Change-Id: Idf80d807572035aa504ec7e013ec3a53b0719738
This commit is contained in:
Dave Borowitz
2013-02-18 11:06:26 -08:00
parent ed6efb08d0
commit 2717dc0741
3 changed files with 23 additions and 2 deletions

View File

@@ -344,16 +344,23 @@ public class ProjectState {
});
}
private void putLabelType(Map<String, LabelType> types, LabelType type) {
LabelType old = types.get(type.getName());
if (old == null || old.canOverride()) {
types.put(type.getName(), type);
}
}
public LabelTypes getLabelTypes() {
Map<String, LabelType> types = Maps.newLinkedHashMap();
for (LabelType type : dbLabelTypes.getLabelTypes()) {
types.put(type.getName(), type);
putLabelType(types, type);
}
List<ProjectState> projects = Lists.newArrayList(tree());
Collections.reverse(projects);
for (ProjectState s : projects) {
for (LabelType type : s.getConfig().getLabelSections()) {
types.put(type.getName(), type);
putLabelType(types, type);
}
}
List<LabelType> all = Lists.newArrayListWithCapacity(types.size());