Remove ApprovalCategory and ApprovalCategoryValue

These can be completely specified in the project config hierarchy and
the database tables are no longer required. Also remove the size limit
on patch_set_approvals.category_id, so new PatchSetApprovals can refer
to label names rather than IDs.

Migrate existing labels into project.config in All-Projects. When
migrating, also convert existing PatchSetApprovals to refer to label
names rather than IDs.

Label IDs are still written to PatchSetApprovals and still supported
in project.config. As of this change, update all code to match
PatchSetApproval's categoryId on either label ID or name.  This allows
for the possibility of database migration without downtime (e.g. for
gerrit-review.googlesource.com). The default schema migration code,
however, does not include label IDs in project.config, since this
schema migration is only intended to run offline.

Change-Id: I5df6f0c5665d0ae4ee6b5e2944f5954fa2f96b5c
This commit is contained in:
Dave Borowitz
2013-02-18 14:53:57 -08:00
parent 6445559a45
commit 8e5de82e56
42 changed files with 566 additions and 795 deletions

View File

@@ -69,7 +69,6 @@ public class ProjectState {
private final PrologEnvironment.Factory envFactory;
private final GitRepositoryManager gitMgr;
private final RulesCache rulesCache;
private final LabelTypes dbLabelTypes;
private final ProjectConfig config;
private final Set<AccountGroup.UUID> localOwners;
@@ -94,7 +93,6 @@ public class ProjectState {
final PrologEnvironment.Factory envFactory,
final GitRepositoryManager gitMgr,
final RulesCache rulesCache,
final LabelTypes labelTypes,
@Assisted final ProjectConfig config) {
this.projectCache = projectCache;
this.isAllProjects = config.getProject().getNameKey().equals(allProjectsName);
@@ -107,7 +105,6 @@ public class ProjectState {
this.capabilities = isAllProjects
? new CapabilityCollection(config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES))
: null;
this.dbLabelTypes = labelTypes;
if (isAllProjects && !Permission.canBeOnAllProjects(AccessSection.ALL, Permission.OWNER)) {
localOwners = Collections.emptySet();
@@ -344,23 +341,16 @@ 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()) {
putLabelType(types, type);
}
List<ProjectState> projects = Lists.newArrayList(tree());
Collections.reverse(projects);
for (ProjectState s : projects) {
for (LabelType type : s.getConfig().getLabelSections()) {
putLabelType(types, type);
for (LabelType type : s.getConfig().getLabelSections().values()) {
LabelType old = types.get(type.getName());
if (old == null || !old.canOverride()) {
types.put(type.getName(), type);
}
}
}
List<LabelType> all = Lists.newArrayListWithCapacity(types.size());