Merge branch 'stable-3.0' into stable-3.1
* stable-3.0:
Upgrade bazlets to latest stable-3.0 to build with 3.0.11 API
Remove the commented-out snapshot plugin api lines
Change-Id: I39916e45822b8d4d657794af356b1d05b22af190
diff --git a/WORKSPACE b/WORKSPACE
index fd3bb12..6d67220 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "7a9ae377b519934c87184cc05845663ed708b69c",
+ commit = "bd8db0cf3057397bcf7287c28cc93886e663989b",
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProject.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProject.java
index 170e0d6..8904144 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/LockUnlockProject.java
@@ -14,8 +14,8 @@
package com.googlesource.gerrit.plugins.renameproject;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.client.ProjectState;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectConfig;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
index db1e862..3625e9a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameCommand.java
@@ -16,9 +16,9 @@
import static com.googlesource.gerrit.plugins.renameproject.RenameProject.WARNING_LIMIT;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.restapi.RestApiException;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectResource;
@@ -66,7 +66,7 @@
input.name = newProjectName;
ProjectResource rsrc =
new ProjectResource(
- projectCacheProvider.get().get(new Project.NameKey(projectControl)), self.get());
+ projectCacheProvider.get().get(Project.nameKey(projectControl)), self.get());
try (CommandProgressMonitor monitor = new CommandProgressMonitor(stdout)) {
renameProject.assertCanRename(rsrc, input, monitor);
List<Change.Id> changeIds = renameProject.getChanges(rsrc, monitor);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameLog.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameLog.java
index 6449cba..e37edb1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameLog.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameLog.java
@@ -16,9 +16,9 @@
import com.google.common.collect.ListMultimap;
import com.google.common.collect.MultimapBuilder;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.systemstatus.ServerInformation;
import com.google.gerrit.json.OutputFormat;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.AuditEvent;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.audit.AuditService;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
index b55a264..41b68a6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RenameProject.java
@@ -20,13 +20,13 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.cache.Cache;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.api.access.PluginPermission;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.extensions.events.PluginEvent;
@@ -152,7 +152,7 @@
pm.beginTask("Checking preconditions");
assertNewNameNotNull(input);
assertRenamePermission(rsrc);
- renamePreconditions.assertCanRename(rsrc, new Project.NameKey(input.name));
+ renamePreconditions.assertCanRename(rsrc, Project.nameKey(input.name));
log.debug("Rename preconditions check successful.");
} catch (CannotRenameProjectException e) {
throw new ResourceConflictException(e.getMessage());
@@ -162,7 +162,7 @@
void doRename(List<Change.Id> changeIds, ProjectResource rsrc, Input input, ProgressMonitor pm)
throws InterruptedException, ConfigInvalidException, IOException, RenameRevertException {
Project.NameKey oldProjectKey = rsrc.getNameKey();
- Project.NameKey newProjectKey = new Project.NameKey(input.name);
+ Project.NameKey newProjectKey = Project.nameKey(input.name);
Exception ex = null;
stepsPerformed.clear();
try {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProject.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProject.java
index 37f261f..72ef4fd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProject.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProject.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.renameproject;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Change.Id;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Change.Id;
+import com.google.gerrit.entities.Project;
import com.google.inject.Inject;
import com.googlesource.gerrit.plugins.renameproject.RenameProject.Step;
import com.googlesource.gerrit.plugins.renameproject.cache.CacheRenameHandler;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/cache/CacheRenameHandler.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/cache/CacheRenameHandler.java
index 4526489..5b16875 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/cache/CacheRenameHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/cache/CacheRenameHandler.java
@@ -14,7 +14,7 @@
package com.googlesource.gerrit.plugins.renameproject.cache;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.project.ProjectCache;
import com.google.inject.Inject;
import com.google.inject.Singleton;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
index 3e30f6e..204c564 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditions.java
@@ -14,15 +14,14 @@
package com.googlesource.gerrit.plugins.renameproject.conditions;
+import com.google.gerrit.entities.BranchNameKey;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.RefNames;
import com.google.gerrit.extensions.common.ProjectInfo;
-import com.google.gerrit.extensions.restapi.RestApiException;
-import com.google.gerrit.reviewdb.client.Branch;
-import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectResource;
import com.google.gerrit.server.restapi.project.ListChildProjects;
import com.google.gerrit.server.submit.MergeOpRepoManager;
@@ -91,17 +90,18 @@
private void assertHasNoChildProjects(ProjectResource rsrc) throws CannotRenameProjectException {
try {
- List<ProjectInfo> children = listChildProjectsProvider.get().apply(rsrc);
- if (!children.isEmpty()) {
+ Response<List<ProjectInfo>> children = listChildProjectsProvider.get().apply(rsrc);
+ if (!children.value().isEmpty()) {
String childrenString =
String.join(
- ", ", children.stream().map(info -> info.name).collect(Collectors.toList()));
+ ", ",
+ children.value().stream().map(info -> info.name).collect(Collectors.toList()));
String message =
String.format("Cannot rename project because it has children: %s", childrenString);
log.error(message);
throw new CannotRenameProjectException(message);
}
- } catch (PermissionBackendException | RestApiException e) {
+ } catch (Exception e) {
throw new CannotRenameProjectException(e);
}
}
@@ -109,12 +109,12 @@
private void assertIsNotSubscribed(Project.NameKey key) throws CannotRenameProjectException {
try (Repository repo = repoManager.openRepository(key);
MergeOpRepoManager orm = ormProvider.get()) {
- Set<Branch.NameKey> branches = new HashSet<>();
- for (Ref ref : repo.getRefDatabase().getRefs(RefNames.REFS_HEADS).values()) {
- branches.add(new Branch.NameKey(key, ref.getName()));
+ Set<BranchNameKey> branches = new HashSet<>();
+ for (Ref ref : repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_HEADS)) {
+ branches.add(BranchNameKey.create(key, ref.getName()));
}
SubmoduleOp sub = subOpFactory.create(branches, orm);
- for (Branch.NameKey b : branches) {
+ for (BranchNameKey b : branches) {
if (!sub.superProjectSubscriptionsForSubmoduleBranch(b).isEmpty()) {
String message = "Cannot rename a project subscribed to by the other projects";
log.error(message);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
index 97cd59f..10a53a0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/DatabaseRenameHandler.java
@@ -16,9 +16,9 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Account;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.ServerInitiated;
import com.google.gerrit.server.account.AccountState;
import com.google.gerrit.server.account.AccountsUpdate;
@@ -121,12 +121,11 @@
private void updateWatchEntries(Project.NameKey newProjectKey)
throws IOException, ConfigInvalidException {
for (AccountState a : accountQueryProvider.get().byWatchedProject(oldProjectKey)) {
- Account.Id accountId = a.getAccount().getId();
- ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches =
- a.getProjectWatches();
+ Account.Id accountId = a.account().id();
+ ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches = a.projectWatches();
Map<ProjectWatchKey, Set<NotifyType>> newProjectWatches = new HashMap<>();
List<ProjectWatchKey> oldProjectWatches = new ArrayList<>();
- for (ProjectWatchKey watchKey : a.getProjectWatches().keySet()) {
+ for (ProjectWatchKey watchKey : a.projectWatches().keySet()) {
if (oldProjectKey.equals(watchKey.project())) {
newProjectWatches.put(
ProjectWatchKey.create(newProjectKey, watchKey.filter()),
@@ -150,14 +149,14 @@
} catch (ConfigInvalidException e) {
log.error(
"Updating watch entry for user {} in project {} failed. Watch config found invalid.",
- a.getUserName(),
+ a.userName(),
newProjectKey.get(),
e);
throw e;
} catch (IOException e) {
log.error(
"Updating watch entry for user {} in project {} failed.",
- a.getUserName(),
+ a.userName(),
newProjectKey.get(),
e);
throw e;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/IndexUpdateHandler.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/IndexUpdateHandler.java
index daef534..5b01391 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/IndexUpdateHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/database/IndexUpdateHandler.java
@@ -15,8 +15,8 @@
package com.googlesource.gerrit.plugins.renameproject.database;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.index.change.ChangeIndexer;
import com.google.inject.Inject;
import com.google.inject.Singleton;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/renameproject/fs/FilesystemRenameHandler.java b/src/main/java/com/googlesource/gerrit/plugins/renameproject/fs/FilesystemRenameHandler.java
index 29a76d8..9294392 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/renameproject/fs/FilesystemRenameHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/renameproject/fs/FilesystemRenameHandler.java
@@ -14,7 +14,7 @@
package com.googlesource.gerrit.plugins.renameproject.fs;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
import com.google.inject.Singleton;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
index 1c26f50..41bd819 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RenameIT.java
@@ -22,10 +22,10 @@
import com.google.gerrit.acceptance.TestPlugin;
import com.google.gerrit.acceptance.UseLocalDisk;
import com.google.gerrit.acceptance.UseSsh;
+import com.google.gerrit.entities.Change.Id;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.Project.NameKey;
import com.google.gerrit.extensions.client.ProjectWatchInfo;
-import com.google.gerrit.reviewdb.client.Change.Id;
-import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.project.ProjectState;
import com.google.inject.Inject;
import java.util.List;
@@ -55,10 +55,10 @@
adminSshSession.exec(PLUGIN_NAME + " " + project.get() + " " + NEW_PROJECT_NAME);
adminSshSession.assertSuccess();
- ProjectState projectState = projectCache.get(new Project.NameKey(NEW_PROJECT_NAME));
+ ProjectState projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
assertThat(projectState).isNotNull();
assertThat(queryProvider.get().byProject(project)).isEmpty();
- assertThat(queryProvider.get().byProject(new Project.NameKey(NEW_PROJECT_NAME))).isNotEmpty();
+ assertThat(queryProvider.get().byProject(Project.nameKey(NEW_PROJECT_NAME))).isNotEmpty();
}
@Test
@@ -69,7 +69,7 @@
adminSshSession.exec(PLUGIN_NAME + " " + project.get() + " " + newProjectName);
adminSshSession.assertFailure();
- ProjectState projectState = projectCache.get(new Project.NameKey(newProjectName));
+ ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
assertThat(projectState).isNull();
}
@@ -80,7 +80,7 @@
adminSshSession.exec(PLUGIN_NAME + " " + allProjects.get() + " " + NEW_PROJECT_NAME);
adminSshSession.assertFailure();
- ProjectState projectState = projectCache.get(new Project.NameKey(NEW_PROJECT_NAME));
+ ProjectState projectState = projectCache.get(Project.nameKey(NEW_PROJECT_NAME));
assertThat(projectState).isNull();
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
index d060414..c13f2e6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/RevertRenameProjectTest.java
@@ -21,10 +21,10 @@
import com.google.gerrit.acceptance.PushOneCommit.Result;
import com.google.gerrit.acceptance.TestPlugin;
import com.google.gerrit.acceptance.UseLocalDisk;
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.common.ChangeInfo;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.project.ProjectResource;
import com.google.gerrit.server.project.ProjectState;
import com.googlesource.gerrit.plugins.renameproject.RenameProject.Step;
@@ -54,7 +54,7 @@
revertRenameProject = plugin.getSysInjector().getInstance(RevertRenameProject.class);
oldProjectKey = project;
- newProjectKey = new Project.NameKey(NEW_PROJECT_NAME);
+ newProjectKey = Project.nameKey(NEW_PROJECT_NAME);
pm = Mockito.mock(ProgressMonitor.class);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/SubmoduleUtil.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/SubmoduleUtil.java
index 68515c4..be4dc37 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/SubmoduleUtil.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/SubmoduleUtil.java
@@ -17,7 +17,7 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.gerrit.common.data.SubscribeSection;
-import com.google.gerrit.reviewdb.client.Project.NameKey;
+import com.google.gerrit.entities.Project.NameKey;
import com.google.gerrit.server.git.meta.MetaDataUpdate;
import com.google.gerrit.server.git.meta.MetaDataUpdate.Server;
import com.google.gerrit.server.project.ProjectCache;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditionsTest.java b/src/test/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditionsTest.java
index e42e550..adc0791 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditionsTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/renameproject/conditions/RenamePreconditionsTest.java
@@ -17,11 +17,14 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.gerrit.entities.Project;
import com.google.gerrit.extensions.common.ProjectInfo;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.config.AllProjectsName;
+import com.google.gerrit.server.config.AllProjectsNameProvider;
import com.google.gerrit.server.config.AllUsersName;
+import com.google.gerrit.server.config.AllUsersNameProvider;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.project.ProjectResource;
import com.google.gerrit.server.project.ProjectState;
@@ -43,8 +46,6 @@
@RunWith(MockitoJUnitRunner.class)
public class RenamePreconditionsTest {
- @Mock private AllProjectsName allProjects;
- @Mock private AllUsersName allUsersName;
@Mock private Provider<ListChildProjects> listChildProjectsProvider;
@Mock private GitRepositoryManager repoManager;
@Mock private SubmoduleOp.Factory subOpFactory;
@@ -56,12 +57,16 @@
@Mock private Repository repo;
@Mock private ListChildProjects listChildProjects;
+ private AllProjectsName allProjects;
+ private AllUsersName allUsersName;
private ProjectResource oldRsrc;
- private List<ProjectInfo> children = new ArrayList<>();
- private Project.NameKey newProjectKey = new Project.NameKey("newProject");
+ private Response<List<ProjectInfo>> children = Response.ok(new ArrayList<>());
+ private Project.NameKey newProjectKey = Project.nameKey("newProject");
@Before
public void setUp() throws Exception {
+ allProjects = new AllProjectsName(AllProjectsNameProvider.DEFAULT);
+ allUsersName = new AllUsersName(AllUsersNameProvider.DEFAULT);
oldRsrc = new ProjectResource(control, user);
when(repoManager.openRepository(newProjectKey)).thenReturn(repo);
when(repo.getObjectDatabase()).thenReturn(objDb);
@@ -102,13 +107,13 @@
@Test(expected = CannotRenameProjectException.class)
public void testAssertCannotRenameHasChildren() throws Exception {
- Project oldProject = new Project(new Project.NameKey("oldProject"));
+ Project oldProject = new Project(Project.nameKey("oldProject"));
when(oldRsrc.getNameKey()).thenReturn(oldProject.getNameKey());
when(objDb.exists()).thenReturn(false);
when(listChildProjectsProvider.get()).thenReturn(listChildProjects);
ProjectInfo projInfo = mock(ProjectInfo.class);
- children.add(projInfo);
+ children.value().add(projInfo);
when(listChildProjects.apply(oldRsrc)).thenReturn(children);
preconditions.assertCanRename(oldRsrc, newProjectKey);