Merge branch 'stable-2.12'
* stable-2.12: ResourceServlet: Fix refreshing stale resources Skip non-existent projects when migrating to schema version 108 rest-api-changes.txt: Make anchor names consistent SiteIndexer: Always scan changes from repo/db Update download-commands plugin Handle new CommitMergeStatus REBASE_MERGE_CONFLICT in MergeOp Make JdbcUtil#port() public Allow to use GWTORM Key classes in plugins Update 2.12 release notes Update JGit to 4.1.1.201511131810-r Set version to 2.12 dev-plugins: Correct missing @Inject annotation Mention that "submit whole topic" is experimental. Change-Id: Ic567729ba8a90799cbaa7219b624f7e4720afa79
This commit is contained in:
@@ -14,14 +14,17 @@
|
||||
|
||||
package com.google.gerrit.server.schema;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.Project.NameKey;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
@@ -44,6 +47,7 @@ import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
|
||||
public class Schema_108 extends SchemaVersion {
|
||||
private final GitRepositoryManager repoManager;
|
||||
@@ -59,7 +63,7 @@ public class Schema_108 extends SchemaVersion {
|
||||
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
|
||||
ui.message("Listing all changes ...");
|
||||
SetMultimap<Project.NameKey, Change.Id> openByProject =
|
||||
getOpenChangesByProject(db);
|
||||
getOpenChangesByProject(db, ui);
|
||||
ui.message("done");
|
||||
|
||||
ui.message("Updating groups for open changes ...");
|
||||
@@ -140,7 +144,9 @@ public class Schema_108 extends SchemaVersion {
|
||||
}
|
||||
|
||||
private SetMultimap<Project.NameKey, Change.Id> getOpenChangesByProject(
|
||||
ReviewDb db) throws OrmException {
|
||||
ReviewDb db, UpdateUI ui) throws OrmException {
|
||||
SortedSet<NameKey> projects = repoManager.list();
|
||||
SortedSet<NameKey> nonExistentProjects = Sets.newTreeSet();
|
||||
SetMultimap<Project.NameKey, Change.Id> openByProject =
|
||||
HashMultimap.create();
|
||||
for (Change c : db.changes().all()) {
|
||||
@@ -149,10 +155,22 @@ public class Schema_108 extends SchemaVersion {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The old "submitted" state is not supported anymore
|
||||
// (thus status is null) but it was an opened state and needs
|
||||
// to be migrated as such
|
||||
openByProject.put(c.getProject(), c.getId());
|
||||
NameKey projectKey = c.getProject();
|
||||
if (!projects.contains(projectKey)) {
|
||||
nonExistentProjects.add(projectKey);
|
||||
} else {
|
||||
// The old "submitted" state is not supported anymore
|
||||
// (thus status is null) but it was an opened state and needs
|
||||
// to be migrated as such
|
||||
openByProject.put(projectKey, c.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (!nonExistentProjects.isEmpty()) {
|
||||
ui.message("Detected open changes referring to the following non-existent projects:");
|
||||
ui.message(Joiner.on(", ").join(nonExistentProjects));
|
||||
ui.message("It is highly recommended to remove\n"
|
||||
+ "the obsolete open changes, comments and patch-sets from your DB.\n");
|
||||
}
|
||||
return openByProject;
|
||||
}
|
||||
|
Reference in New Issue
Block a user