Merge branch 'stable-2.11' into stable-2.12
* stable-2.11: SiteIndexer: Always scan changes from repo/db Make JdbcUtil#port() public Allow to use GWTORM Key classes in plugins Change-Id: I90edcb6a930e9125e1a56d19d1765d502eaf25ab
This commit is contained in:
commit
97f939c5eb
@ -99,7 +99,7 @@ public final class Change {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(id = 1)
|
||||
protected int id;
|
||||
public int id;
|
||||
|
||||
protected Id() {
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ public class LabelId extends StringKey<com.google.gwtorm.client.Key<?>> {
|
||||
public static final LabelId SUBMIT = new LabelId("SUBM");
|
||||
|
||||
@Column(id = 1)
|
||||
protected String id;
|
||||
public String id;
|
||||
|
||||
protected LabelId() {
|
||||
public LabelId() {
|
||||
}
|
||||
|
||||
public LabelId(final String n) {
|
||||
|
@ -77,12 +77,12 @@ public final class PatchSet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(id = 1)
|
||||
protected Change.Id changeId;
|
||||
public Change.Id changeId;
|
||||
|
||||
@Column(id = 2)
|
||||
protected int patchSetId;
|
||||
public int patchSetId;
|
||||
|
||||
protected Id() {
|
||||
public Id() {
|
||||
changeId = new Change.Id();
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
import com.google.gerrit.server.util.ManualRequestContext;
|
||||
import com.google.gerrit.server.util.OneOffRequestContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Singleton;
|
||||
@ -37,6 +38,7 @@ import org.eclipse.jgit.lib.Repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -97,7 +99,14 @@ public class ScanningChangeCacheImpl implements ChangeCache {
|
||||
public List<Change> load(Project.NameKey key) throws Exception {
|
||||
try (Repository repo = repoManager.openRepository(key);
|
||||
ManualRequestContext ctx = requestContext.open()) {
|
||||
ReviewDb db = ctx.getReviewDbProvider().get();
|
||||
return scan(repo, ctx.getReviewDbProvider().get());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<Change> scan(Repository repo, ReviewDb db)
|
||||
throws OrmException, IOException {
|
||||
Map<String, Ref> refs =
|
||||
repo.getRefDatabase().getRefs(RefNames.REFS_CHANGES);
|
||||
Set<Change.Id> ids = new LinkedHashSet<>();
|
||||
@ -116,6 +125,3 @@ public class ScanningChangeCacheImpl implements ChangeCache {
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.git.ChangeCache;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.git.MultiProgressMonitor;
|
||||
import com.google.gerrit.server.git.MultiProgressMonitor.Task;
|
||||
import com.google.gerrit.server.git.ScanningChangeCacheImpl;
|
||||
import com.google.gerrit.server.patch.PatchListLoader;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.SchemaFactory;
|
||||
@ -112,7 +112,6 @@ public class SiteIndexer {
|
||||
}
|
||||
|
||||
private final SchemaFactory<ReviewDb> schemaFactory;
|
||||
private final ChangeCache changeCache;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final ListeningExecutorService executor;
|
||||
@ -126,14 +125,12 @@ public class SiteIndexer {
|
||||
|
||||
@Inject
|
||||
SiteIndexer(SchemaFactory<ReviewDb> schemaFactory,
|
||||
ChangeCache changeCache,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
GitRepositoryManager repoManager,
|
||||
@IndexExecutor(BATCH) ListeningExecutorService executor,
|
||||
ChangeIndexer.Factory indexerFactory,
|
||||
@GerritServerConfig Config config) {
|
||||
this.schemaFactory = schemaFactory;
|
||||
this.changeCache = changeCache;
|
||||
this.changeDataFactory = changeDataFactory;
|
||||
this.repoManager = repoManager;
|
||||
this.executor = executor;
|
||||
@ -241,7 +238,7 @@ public class SiteIndexer {
|
||||
try (Repository repo = repoManager.openRepository(project);
|
||||
ReviewDb db = schemaFactory.open()) {
|
||||
Map<String, Ref> refs = repo.getRefDatabase().getRefs(ALL);
|
||||
for (Change c : changeCache.get(project)) {
|
||||
for (Change c : ScanningChangeCacheImpl.scan(repo, db)) {
|
||||
Ref r = refs.get(c.currentPatchSetId().toRefName());
|
||||
if (r != null) {
|
||||
byId.put(r.getObjectId(), changeDataFactory.create(db, c));
|
||||
|
@ -26,7 +26,7 @@ public class JdbcUtil {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
static String port(String port) {
|
||||
public static String port(String port) {
|
||||
if (port != null && !port.isEmpty()) {
|
||||
return ":" + port;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user