Move "refs/..." constants to a RefNames class

This class lives in gerrit-reviewdb because "refs/changes/" needs to be
referenced from PatchSet in reviewdb/client (and other UI classes).

Rename constants to all use REFS_* instead of being inconsistent.

Change-Id: I76e6ee7e63a4549b51a43698fb50b54a19dabfc6
This commit is contained in:
Dave Borowitz
2013-12-11 08:55:24 -08:00
parent 2f7cb5997f
commit 31b599b40f
40 changed files with 150 additions and 105 deletions

View File

@@ -29,6 +29,7 @@ import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.data.PermissionRule.Action;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.config.AllProjectsName;
@@ -97,7 +98,7 @@ public class AllProjectsCreator {
initAllProjects(git);
RefUpdate u = git.updateRef(Constants.HEAD);
u.link(GitRepositoryManager.REF_CONFIG);
u.link(RefNames.REFS_CONFIG);
} catch (RepositoryNotFoundException err) {
String name = allProjectsName.get();
throw new IOException("Cannot create repository " + name, err);
@@ -131,7 +132,7 @@ public class AllProjectsCreator {
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
AccessSection heads = config.getAccessSection(AccessSection.HEADS, true);
AccessSection tags = config.getAccessSection("refs/tags/*", true);
AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true);
AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true);
AccessSection magic = config.getAccessSection("refs/for/" + AccessSection.ALL, true);
grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin);

View File

@@ -32,6 +32,7 @@ import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.PatchSetApproval.LabelId;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
@@ -186,7 +187,7 @@ class Schema_53 extends SchemaVersion {
// Grant out read on the config branch by default.
//
if (config.getProject().getNameKey().equals(systemConfig.wildProjectName)) {
AccessSection meta = config.getAccessSection(GitRepositoryManager.REF_CONFIG, true);
AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true);
Permission read = meta.getPermission(READ, true);
read.getRule(config.resolve(projectOwners), true);
}

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.schema;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
@@ -44,8 +45,8 @@ public class Schema_56 extends SchemaVersion {
keysOne = new HashSet<String>();
keysTwo = new HashSet<String>();
keysOne.add(GitRepositoryManager.REF_CONFIG);
keysTwo.add(GitRepositoryManager.REF_CONFIG);
keysOne.add(RefNames.REFS_CONFIG);
keysTwo.add(RefNames.REFS_CONFIG);
keysTwo.add(Constants.HEAD);
}
@@ -73,10 +74,10 @@ public class Schema_56 extends SchemaVersion {
try {
RefUpdate update = git.updateRef(Constants.HEAD);
update.disableRefLog();
update.link(GitRepositoryManager.REF_CONFIG);
update.link(RefNames.REFS_CONFIG);
} catch (IOException err) {
ui.message("warning: " + name.get() + ": Cannot update HEAD to "
+ GitRepositoryManager.REF_CONFIG + ": " + err.getMessage());
+ RefNames.REFS_CONFIG + ": " + err.getMessage());
}
}
} finally {