Remove ReviewDb from ChangeData
Propagate the removal out to some downstream interfaces as well. Ironically, in at least one case, we needed to *add* a Provider<ReviewDb> to a class, since it was using ChangeData#db() as the argument to another method which hasn't yet had this argument removed. Change-Id: I42b1609e402d7dd552ea67197d21c28051261ee8
This commit is contained in:
@@ -1130,7 +1130,7 @@ public abstract class AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected PatchSet getPatchSet(PatchSet.Id psId) throws OrmException {
|
protected PatchSet getPatchSet(PatchSet.Id psId) throws OrmException {
|
||||||
return changeDataFactory.create(db, project, psId.getParentKey()).patchSet(psId);
|
return changeDataFactory.create(project, psId.getParentKey()).patchSet(psId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IdentifiedUser user(TestAccount testAccount) {
|
protected IdentifiedUser user(TestAccount testAccount) {
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import com.google.gerrit.reviewdb.client.Change.Id;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.converter.PatchSetApprovalProtoConverter;
|
import com.google.gerrit.reviewdb.converter.PatchSetApprovalProtoConverter;
|
||||||
import com.google.gerrit.reviewdb.converter.PatchSetProtoConverter;
|
import com.google.gerrit.reviewdb.converter.PatchSetProtoConverter;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ReviewerByEmailSet;
|
import com.google.gerrit.server.ReviewerByEmailSet;
|
||||||
import com.google.gerrit.server.ReviewerSet;
|
import com.google.gerrit.server.ReviewerSet;
|
||||||
import com.google.gerrit.server.StarredChangesUtil;
|
import com.google.gerrit.server.StarredChangesUtil;
|
||||||
@@ -61,7 +60,6 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -93,20 +91,17 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
|||||||
private static final String CLOSED_CHANGES = "closed_" + CHANGES;
|
private static final String CLOSED_CHANGES = "closed_" + CHANGES;
|
||||||
|
|
||||||
private final ChangeMapping mapping;
|
private final ChangeMapping mapping;
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Schema<ChangeData> schema;
|
private final Schema<ChangeData> schema;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ElasticChangeIndex(
|
ElasticChangeIndex(
|
||||||
ElasticConfiguration cfg,
|
ElasticConfiguration cfg,
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
SitePaths sitePaths,
|
SitePaths sitePaths,
|
||||||
ElasticRestClientProvider clientBuilder,
|
ElasticRestClientProvider clientBuilder,
|
||||||
@Assisted Schema<ChangeData> schema) {
|
@Assisted Schema<ChangeData> schema) {
|
||||||
super(cfg, sitePaths, schema, clientBuilder, CHANGES);
|
super(cfg, sitePaths, schema, clientBuilder, CHANGES);
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
mapping = new ChangeMapping(schema, client.adapter());
|
mapping = new ChangeMapping(schema, client.adapter());
|
||||||
@@ -219,13 +214,11 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
|||||||
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
||||||
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
||||||
String projectName = requireNonNull(source.get(ChangeField.PROJECT.getName()).getAsString());
|
String projectName = requireNonNull(source.get(ChangeField.PROJECT.getName()).getAsString());
|
||||||
return changeDataFactory.create(
|
return changeDataFactory.create(new Project.NameKey(projectName), new Change.Id(id));
|
||||||
db.get(), new Project.NameKey(projectName), new Change.Id(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeData cd =
|
ChangeData cd =
|
||||||
changeDataFactory.create(
|
changeDataFactory.create(CHANGE_CODEC.decode(Base64.decodeBase64(c.getAsString())));
|
||||||
db.get(), CHANGE_CODEC.decode(Base64.decodeBase64(c.getAsString())));
|
|
||||||
|
|
||||||
// Any decoding that is done here must also be done in {@link LuceneChangeIndex}.
|
// Any decoding that is done here must also be done in {@link LuceneChangeIndex}.
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ import com.google.gerrit.reviewdb.client.Project;
|
|||||||
import com.google.gerrit.reviewdb.converter.PatchSetApprovalProtoConverter;
|
import com.google.gerrit.reviewdb.converter.PatchSetApprovalProtoConverter;
|
||||||
import com.google.gerrit.reviewdb.converter.PatchSetProtoConverter;
|
import com.google.gerrit.reviewdb.converter.PatchSetProtoConverter;
|
||||||
import com.google.gerrit.reviewdb.converter.ProtoConverter;
|
import com.google.gerrit.reviewdb.converter.ProtoConverter;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.StarredChangesUtil;
|
import com.google.gerrit.server.StarredChangesUtil;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
@@ -65,7 +64,6 @@ import com.google.gwtorm.server.OrmException;
|
|||||||
import com.google.gwtorm.server.OrmRuntimeException;
|
import com.google.gwtorm.server.OrmRuntimeException;
|
||||||
import com.google.gwtorm.server.ResultSet;
|
import com.google.gwtorm.server.ResultSet;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.protobuf.MessageLite;
|
import com.google.protobuf.MessageLite;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -145,7 +143,6 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final ListeningExecutorService executor;
|
private final ListeningExecutorService executor;
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Schema<ChangeData> schema;
|
private final Schema<ChangeData> schema;
|
||||||
private final QueryBuilder<ChangeData> queryBuilder;
|
private final QueryBuilder<ChangeData> queryBuilder;
|
||||||
@@ -157,12 +154,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
@GerritServerConfig Config cfg,
|
@GerritServerConfig Config cfg,
|
||||||
SitePaths sitePaths,
|
SitePaths sitePaths,
|
||||||
@IndexExecutor(INTERACTIVE) ListeningExecutorService executor,
|
@IndexExecutor(INTERACTIVE) ListeningExecutorService executor,
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
@Assisted Schema<ChangeData> schema)
|
@Assisted Schema<ChangeData> schema)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.schema = schema;
|
this.schema = schema;
|
||||||
|
|
||||||
@@ -450,15 +445,13 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
IndexableField cb = Iterables.getFirst(doc.get(CHANGE_FIELD), null);
|
IndexableField cb = Iterables.getFirst(doc.get(CHANGE_FIELD), null);
|
||||||
if (cb != null) {
|
if (cb != null) {
|
||||||
BytesRef proto = cb.binaryValue();
|
BytesRef proto = cb.binaryValue();
|
||||||
cd =
|
cd = changeDataFactory.create(CHANGE_CODEC.decode(proto.bytes, proto.offset, proto.length));
|
||||||
changeDataFactory.create(
|
|
||||||
db.get(), CHANGE_CODEC.decode(proto.bytes, proto.offset, proto.length));
|
|
||||||
} else {
|
} else {
|
||||||
IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
|
IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
|
||||||
Change.Id id = new Change.Id(f.numericValue().intValue());
|
Change.Id id = new Change.Id(f.numericValue().intValue());
|
||||||
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
||||||
IndexableField project = doc.get(PROJECT.getName()).iterator().next();
|
IndexableField project = doc.get(PROJECT.getName()).iterator().next();
|
||||||
cd = changeDataFactory.create(db.get(), new Project.NameKey(project.stringValue()), id);
|
cd = changeDataFactory.create(new Project.NameKey(project.stringValue()), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any decoding that is done here must also be done in {@link ElasticChangeIndex}.
|
// Any decoding that is done here must also be done in {@link ElasticChangeIndex}.
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.google.gerrit.extensions.client.ChangeKind;
|
|||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.change.ChangeKindCache;
|
import com.google.gerrit.server.change.ChangeKindCache;
|
||||||
import com.google.gerrit.server.change.LabelNormalizer;
|
import com.google.gerrit.server.change.LabelNormalizer;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
@@ -74,18 +73,12 @@ public class ApprovalCopier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Iterable<PatchSetApproval> getForPatchSet(
|
Iterable<PatchSetApproval> getForPatchSet(
|
||||||
ReviewDb db,
|
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||||
ChangeNotes notes,
|
|
||||||
PatchSet.Id psId,
|
|
||||||
@Nullable RevWalk rw,
|
|
||||||
@Nullable Config repoConfig)
|
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return getForPatchSet(
|
return getForPatchSet(notes, psId, rw, repoConfig, Collections.<PatchSetApproval>emptyList());
|
||||||
db, notes, psId, rw, repoConfig, Collections.<PatchSetApproval>emptyList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<PatchSetApproval> getForPatchSet(
|
Iterable<PatchSetApproval> getForPatchSet(
|
||||||
ReviewDb db,
|
|
||||||
ChangeNotes notes,
|
ChangeNotes notes,
|
||||||
PatchSet.Id psId,
|
PatchSet.Id psId,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@@ -96,11 +89,10 @@ public class ApprovalCopier {
|
|||||||
if (ps == null) {
|
if (ps == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return getForPatchSet(db, notes, ps, rw, repoConfig, dontCopy);
|
return getForPatchSet(notes, ps, rw, repoConfig, dontCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<PatchSetApproval> getForPatchSet(
|
private Iterable<PatchSetApproval> getForPatchSet(
|
||||||
ReviewDb db,
|
|
||||||
ChangeNotes notes,
|
ChangeNotes notes,
|
||||||
PatchSet ps,
|
PatchSet ps,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@@ -108,7 +100,7 @@ public class ApprovalCopier {
|
|||||||
Iterable<PatchSetApproval> dontCopy)
|
Iterable<PatchSetApproval> dontCopy)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
requireNonNull(ps, "ps should not be null");
|
requireNonNull(ps, "ps should not be null");
|
||||||
ChangeData cd = changeDataFactory.create(db, notes);
|
ChangeData cd = changeDataFactory.create(notes);
|
||||||
try {
|
try {
|
||||||
ProjectState project = projectCache.checkedGet(cd.change().getDest().getParentKey());
|
ProjectState project = projectCache.checkedGet(cd.change().getDest().getParentKey());
|
||||||
ListMultimap<PatchSet.Id, PatchSetApproval> all = cd.approvals();
|
ListMultimap<PatchSet.Id, PatchSetApproval> all = cd.approvals();
|
||||||
|
|||||||
@@ -350,24 +350,19 @@ public class ApprovalsUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<PatchSetApproval> byPatchSet(
|
public Iterable<PatchSetApproval> byPatchSet(
|
||||||
ReviewDb db,
|
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||||
ChangeNotes notes,
|
|
||||||
PatchSet.Id psId,
|
|
||||||
@Nullable RevWalk rw,
|
|
||||||
@Nullable Config repoConfig)
|
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return copier.getForPatchSet(db, notes, psId, rw, repoConfig);
|
return copier.getForPatchSet(notes, psId, rw, repoConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<PatchSetApproval> byPatchSetUser(
|
public Iterable<PatchSetApproval> byPatchSetUser(
|
||||||
ReviewDb db,
|
|
||||||
ChangeNotes notes,
|
ChangeNotes notes,
|
||||||
PatchSet.Id psId,
|
PatchSet.Id psId,
|
||||||
Account.Id accountId,
|
Account.Id accountId,
|
||||||
@Nullable RevWalk rw,
|
@Nullable RevWalk rw,
|
||||||
@Nullable Config repoConfig)
|
@Nullable Config repoConfig)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return filterApprovals(byPatchSet(db, notes, psId, rw, repoConfig), accountId);
|
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSetApproval getSubmitter(ChangeNotes notes, PatchSet.Id c) {
|
public PatchSetApproval getSubmitter(ChangeNotes notes, PatchSet.Id c) {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RevId;
|
import com.google.gerrit.reviewdb.client.RevId;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||||
@@ -52,18 +51,15 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
|||||||
public class PatchSetUtil {
|
public class PatchSetUtil {
|
||||||
private final Provider<ApprovalsUtil> approvalsUtilProvider;
|
private final Provider<ApprovalsUtil> approvalsUtilProvider;
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
|
||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PatchSetUtil(
|
PatchSetUtil(
|
||||||
Provider<ApprovalsUtil> approvalsUtilProvider,
|
Provider<ApprovalsUtil> approvalsUtilProvider,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
Provider<ReviewDb> dbProvider,
|
|
||||||
GitRepositoryManager repoManager) {
|
GitRepositoryManager repoManager) {
|
||||||
this.approvalsUtilProvider = approvalsUtilProvider;
|
this.approvalsUtilProvider = approvalsUtilProvider;
|
||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.dbProvider = dbProvider;
|
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +155,7 @@ public class PatchSetUtil {
|
|||||||
|
|
||||||
ApprovalsUtil approvalsUtil = approvalsUtilProvider.get();
|
ApprovalsUtil approvalsUtil = approvalsUtilProvider.get();
|
||||||
for (PatchSetApproval ap :
|
for (PatchSetApproval ap :
|
||||||
approvalsUtil.byPatchSet(dbProvider.get(), notes, change.currentPatchSetId(), null, null)) {
|
approvalsUtil.byPatchSet(notes, change.currentPatchSetId(), null, null)) {
|
||||||
LabelType type = projectState.getLabelTypes(notes).byLabel(ap.getLabel());
|
LabelType type = projectState.getLabelTypes(notes).byLabel(ap.getLabel());
|
||||||
if (type != null
|
if (type != null
|
||||||
&& ap.getValue() == 1
|
&& ap.getValue() == 1
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.config.AllUsersName;
|
import com.google.gerrit.server.config.AllUsersName;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
@@ -167,7 +166,6 @@ public class StarredChangesUtil {
|
|||||||
private final GitRepositoryManager repoManager;
|
private final GitRepositoryManager repoManager;
|
||||||
private final GitReferenceUpdated gitRefUpdated;
|
private final GitReferenceUpdated gitRefUpdated;
|
||||||
private final AllUsersName allUsers;
|
private final AllUsersName allUsers;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
|
||||||
private final Provider<PersonIdent> serverIdent;
|
private final Provider<PersonIdent> serverIdent;
|
||||||
private final ChangeIndexer indexer;
|
private final ChangeIndexer indexer;
|
||||||
private final Provider<InternalChangeQuery> queryProvider;
|
private final Provider<InternalChangeQuery> queryProvider;
|
||||||
@@ -177,14 +175,12 @@ public class StarredChangesUtil {
|
|||||||
GitRepositoryManager repoManager,
|
GitRepositoryManager repoManager,
|
||||||
GitReferenceUpdated gitRefUpdated,
|
GitReferenceUpdated gitRefUpdated,
|
||||||
AllUsersName allUsers,
|
AllUsersName allUsers,
|
||||||
Provider<ReviewDb> dbProvider,
|
|
||||||
@GerritPersonIdent Provider<PersonIdent> serverIdent,
|
@GerritPersonIdent Provider<PersonIdent> serverIdent,
|
||||||
ChangeIndexer indexer,
|
ChangeIndexer indexer,
|
||||||
Provider<InternalChangeQuery> queryProvider) {
|
Provider<InternalChangeQuery> queryProvider) {
|
||||||
this.repoManager = repoManager;
|
this.repoManager = repoManager;
|
||||||
this.gitRefUpdated = gitRefUpdated;
|
this.gitRefUpdated = gitRefUpdated;
|
||||||
this.allUsers = allUsers;
|
this.allUsers = allUsers;
|
||||||
this.dbProvider = dbProvider;
|
|
||||||
this.serverIdent = serverIdent;
|
this.serverIdent = serverIdent;
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.queryProvider = queryProvider;
|
this.queryProvider = queryProvider;
|
||||||
@@ -229,7 +225,7 @@ public class StarredChangesUtil {
|
|||||||
updateLabels(repo, refName, old.objectId(), labels);
|
updateLabels(repo, refName, old.objectId(), labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
indexer.index(dbProvider.get(), project, changeId);
|
indexer.index(project, changeId);
|
||||||
return ImmutableSortedSet.copyOf(labels);
|
return ImmutableSortedSet.copyOf(labels);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new OrmException(
|
throw new OrmException(
|
||||||
@@ -259,7 +255,7 @@ public class StarredChangesUtil {
|
|||||||
changeId.get(), command.getRefName(), command.getResult()));
|
changeId.get(), command.getRefName(), command.getResult()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
indexer.index(dbProvider.get(), project, changeId);
|
indexer.index(project, changeId);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e);
|
throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,11 +268,11 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(ChangeResource rsrc) throws OrmException {
|
public ChangeInfo format(ChangeResource rsrc) throws OrmException {
|
||||||
return format(changeDataFactory.create(db.get(), rsrc.getNotes()));
|
return format(changeDataFactory.create(rsrc.getNotes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(Change change) throws OrmException {
|
public ChangeInfo format(Change change) throws OrmException {
|
||||||
return format(changeDataFactory.create(db.get(), change));
|
return format(changeDataFactory.create(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws OrmException {
|
public ChangeInfo format(Project.NameKey project, Change.Id id) throws OrmException {
|
||||||
@@ -284,7 +284,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInfo format(RevisionResource rsrc) throws OrmException {
|
public ChangeInfo format(RevisionResource rsrc) throws OrmException {
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,10 +328,9 @@ public class ChangeJson {
|
|||||||
if (!has(CHECK)) {
|
if (!has(CHECK)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return checkOnly(changeDataFactory.create(db.get(), project, id), changeInfoSupplier);
|
return checkOnly(changeDataFactory.create(project, id), changeInfoSupplier);
|
||||||
}
|
}
|
||||||
return format(
|
return format(changeDataFactory.create(notes), Optional.empty(), true, changeInfoSupplier);
|
||||||
changeDataFactory.create(db.get(), notes), Optional.empty(), true, changeInfoSupplier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Collection<SubmitRequirementInfo> requirementsFor(ChangeData cd) {
|
private static Collection<SubmitRequirementInfo> requirementsFor(ChangeData cd) {
|
||||||
@@ -496,7 +495,7 @@ public class ChangeJson {
|
|||||||
// If any problems were fixed, the ChangeData needs to be reloaded.
|
// If any problems were fixed, the ChangeData needs to be reloaded.
|
||||||
for (ProblemInfo p : out.problems) {
|
for (ProblemInfo p : out.problems) {
|
||||||
if (p.status == ProblemInfo.Status.FIXED) {
|
if (p.status == ProblemInfo.Status.FIXED) {
|
||||||
cd = changeDataFactory.create(cd.db(), cd.project(), cd.getId());
|
cd = changeDataFactory.create(cd.project(), cd.getId());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeKind getChangeKind(ReviewDb db, Change change, PatchSet patch) {
|
public ChangeKind getChangeKind(ReviewDb db, Change change, PatchSet patch) {
|
||||||
return getChangeKindInternal(this, db, change, patch, changeDataFactory, repoManager);
|
return getChangeKindInternal(this, change, patch, changeDataFactory, repoManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -351,7 +351,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeKind getChangeKind(ReviewDb db, Change change, PatchSet patch) {
|
public ChangeKind getChangeKind(ReviewDb db, Change change, PatchSet patch) {
|
||||||
return getChangeKindInternal(this, db, change, patch, changeDataFactory, repoManager);
|
return getChangeKindInternal(this, change, patch, changeDataFactory, repoManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -406,7 +406,6 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
|||||||
|
|
||||||
private static ChangeKind getChangeKindInternal(
|
private static ChangeKind getChangeKindInternal(
|
||||||
ChangeKindCache cache,
|
ChangeKindCache cache,
|
||||||
ReviewDb db,
|
|
||||||
Change change,
|
Change change,
|
||||||
PatchSet patch,
|
PatchSet patch,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
@@ -420,7 +419,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
|||||||
RevWalk rw = new RevWalk(repo)) {
|
RevWalk rw = new RevWalk(repo)) {
|
||||||
kind =
|
kind =
|
||||||
getChangeKindInternal(
|
getChangeKindInternal(
|
||||||
cache, rw, repo.getConfig(), changeDataFactory.create(db, change), patch);
|
cache, rw, repo.getConfig(), changeDataFactory.create(change), patch);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Do nothing; assume we have a complex change
|
// Do nothing; assume we have a complex change
|
||||||
logger.atWarning().withCause(e).log(
|
logger.atWarning().withCause(e).log(
|
||||||
|
|||||||
@@ -263,7 +263,6 @@ public class LabelsJson {
|
|||||||
Map<String, Short> result = new HashMap<>();
|
Map<String, Short> result = new HashMap<>();
|
||||||
for (PatchSetApproval psa :
|
for (PatchSetApproval psa :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
db.get(),
|
|
||||||
lazyLoad ? cd.notes() : notesFactory.createFromIndexedChange(cd.change()),
|
lazyLoad ? cd.notes() : notesFactory.createFromIndexedChange(cd.change()),
|
||||||
cd.change().currentPatchSetId(),
|
cd.change().currentPatchSetId(),
|
||||||
accountId,
|
accountId,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class ReviewerJson {
|
|||||||
ChangeData cd = null;
|
ChangeData cd = null;
|
||||||
for (ReviewerResource rsrc : rsrcs) {
|
for (ReviewerResource rsrc : rsrcs) {
|
||||||
if (cd == null || !cd.getId().equals(rsrc.getChangeId())) {
|
if (cd == null || !cd.getId().equals(rsrc.getChangeId())) {
|
||||||
cd = changeDataFactory.create(db.get(), rsrc.getChangeResource().getNotes());
|
cd = changeDataFactory.create(rsrc.getChangeResource().getNotes());
|
||||||
}
|
}
|
||||||
ReviewerInfo info;
|
ReviewerInfo info;
|
||||||
if (rsrc.isByEmail()) {
|
if (rsrc.isByEmail()) {
|
||||||
@@ -105,7 +105,7 @@ public class ReviewerJson {
|
|||||||
out,
|
out,
|
||||||
reviewerAccountId,
|
reviewerAccountId,
|
||||||
cd,
|
cd,
|
||||||
approvalsUtil.byPatchSetUser(db.get(), cd.notes(), psId, reviewerAccountId, null, null));
|
approvalsUtil.byPatchSetUser(cd.notes(), psId, reviewerAccountId, null, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReviewerInfo format(
|
public ReviewerInfo format(
|
||||||
|
|||||||
@@ -628,6 +628,6 @@ public class ChangeEditModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void reindex(Change change) throws IOException {
|
private void reindex(Change change) throws IOException {
|
||||||
indexer.index(reviewDb.get(), change);
|
indexer.index(change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ public class ChangeEditUtil {
|
|||||||
try (Repository repo = gitManager.openRepository(change.getProject())) {
|
try (Repository repo = gitManager.openRepository(change.getProject())) {
|
||||||
deleteRef(repo, edit);
|
deleteRef(repo, edit);
|
||||||
}
|
}
|
||||||
indexer.index(db.get(), change);
|
indexer.index(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PatchSet getBasePatchSet(ChangeNotes notes, Ref ref) throws IOException {
|
private PatchSet getBasePatchSet(ChangeNotes notes, Ref ref) throws IOException {
|
||||||
|
|||||||
@@ -128,23 +128,7 @@ public class EventFactory {
|
|||||||
* @param change
|
* @param change
|
||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) {
|
public ChangeAttribute asChangeAttribute(Change change) {
|
||||||
try (ReviewDb db = schema.open()) {
|
|
||||||
return asChangeAttribute(db, change, notes);
|
|
||||||
} catch (OrmException e) {
|
|
||||||
logger.atSevere().withCause(e).log("Cannot open database connection");
|
|
||||||
return new ChangeAttribute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a ChangeAttribute for the given change suitable for serialization to JSON.
|
|
||||||
*
|
|
||||||
* @param db Review database
|
|
||||||
* @param change
|
|
||||||
* @return object suitable for serialization to JSON
|
|
||||||
*/
|
|
||||||
public ChangeAttribute asChangeAttribute(ReviewDb db, Change change) {
|
|
||||||
ChangeAttribute a = new ChangeAttribute();
|
ChangeAttribute a = new ChangeAttribute();
|
||||||
a.project = change.getProject().get();
|
a.project = change.getProject().get();
|
||||||
a.branch = change.getDest().getShortName();
|
a.branch = change.getDest().getShortName();
|
||||||
@@ -153,7 +137,7 @@ public class EventFactory {
|
|||||||
a.number = change.getId().get();
|
a.number = change.getId().get();
|
||||||
a.subject = change.getSubject();
|
a.subject = change.getSubject();
|
||||||
try {
|
try {
|
||||||
a.commitMessage = changeDataFactory.create(db, change).commitMessage();
|
a.commitMessage = changeDataFactory.create(change).commitMessage();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.atSevere().withCause(e).log(
|
logger.atSevere().withCause(e).log(
|
||||||
"Error while getting full commit message for change %d", a.number);
|
"Error while getting full commit message for change %d", a.number);
|
||||||
@@ -171,14 +155,12 @@ public class EventFactory {
|
|||||||
/**
|
/**
|
||||||
* Create a ChangeAttribute for the given change suitable for serialization to JSON.
|
* Create a ChangeAttribute for the given change suitable for serialization to JSON.
|
||||||
*
|
*
|
||||||
* @param db Review database
|
|
||||||
* @param change
|
* @param change
|
||||||
* @param notes
|
* @param notes
|
||||||
* @return object suitable for serialization to JSON
|
* @return object suitable for serialization to JSON
|
||||||
*/
|
*/
|
||||||
public ChangeAttribute asChangeAttribute(ReviewDb db, Change change, ChangeNotes notes)
|
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) throws OrmException {
|
||||||
throws OrmException {
|
ChangeAttribute a = asChangeAttribute(change);
|
||||||
ChangeAttribute a = asChangeAttribute(db, change);
|
|
||||||
Set<String> hashtags = notes.load().getHashtags();
|
Set<String> hashtags = notes.load().getHashtags();
|
||||||
if (!hashtags.isEmpty()) {
|
if (!hashtags.isEmpty()) {
|
||||||
a.hashtags = new ArrayList<>(hashtags.size());
|
a.hashtags = new ArrayList<>(hashtags.size());
|
||||||
|
|||||||
@@ -154,7 +154,11 @@ public class StreamEventsApiListener
|
|||||||
new Supplier<ChangeAttribute>() {
|
new Supplier<ChangeAttribute>() {
|
||||||
@Override
|
@Override
|
||||||
public ChangeAttribute get() {
|
public ChangeAttribute get() {
|
||||||
|
try {
|
||||||
return eventFactory.asChangeAttribute(change, notes);
|
return eventFactory.asChangeAttribute(change, notes);
|
||||||
|
} catch (OrmException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.google.gerrit.reviewdb.client.Account;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.GpgException;
|
import com.google.gerrit.server.GpgException;
|
||||||
import com.google.gerrit.server.account.AccountState;
|
import com.google.gerrit.server.account.AccountState;
|
||||||
import com.google.gerrit.server.change.ChangeJson;
|
import com.google.gerrit.server.change.ChangeJson;
|
||||||
@@ -35,7 +34,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@@ -63,7 +61,6 @@ public class EventUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeJson.Factory changeJsonFactory;
|
private final ChangeJson.Factory changeJsonFactory;
|
||||||
private final RevisionJson.Factory revisionJsonFactory;
|
private final RevisionJson.Factory revisionJsonFactory;
|
||||||
|
|
||||||
@@ -71,10 +68,8 @@ public class EventUtil {
|
|||||||
EventUtil(
|
EventUtil(
|
||||||
ChangeJson.Factory changeJsonFactory,
|
ChangeJson.Factory changeJsonFactory,
|
||||||
RevisionJson.Factory revisionJsonFactory,
|
RevisionJson.Factory revisionJsonFactory,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory) {
|
||||||
Provider<ReviewDb> db) {
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.db = db;
|
|
||||||
this.changeJsonFactory = changeJsonFactory;
|
this.changeJsonFactory = changeJsonFactory;
|
||||||
this.revisionJsonFactory = revisionJsonFactory;
|
this.revisionJsonFactory = revisionJsonFactory;
|
||||||
}
|
}
|
||||||
@@ -92,7 +87,7 @@ public class EventUtil {
|
|||||||
public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps)
|
public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps)
|
||||||
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
|
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
|
||||||
PermissionBackendException {
|
PermissionBackendException {
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), project, ps.getId().getParentKey());
|
ChangeData cd = changeDataFactory.create(project, ps.getId().getParentKey());
|
||||||
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import com.google.gerrit.reviewdb.client.LabelId;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet.Id;
|
import com.google.gerrit.reviewdb.client.PatchSet.Id;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
@@ -58,7 +57,6 @@ import com.google.gerrit.server.submit.MergeIdenticalTreeException;
|
|||||||
import com.google.gerrit.server.submit.MergeSorter;
|
import com.google.gerrit.server.submit.MergeSorter;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -162,7 +160,6 @@ public class MergeUtil {
|
|||||||
MergeUtil create(ProjectState project, boolean useContentMerge);
|
MergeUtil create(ProjectState project, boolean useContentMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final IdentifiedUser.GenericFactory identifiedUserFactory;
|
private final IdentifiedUser.GenericFactory identifiedUserFactory;
|
||||||
private final UrlFormatter urlFormatter;
|
private final UrlFormatter urlFormatter;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
@@ -174,7 +171,6 @@ public class MergeUtil {
|
|||||||
@AssistedInject
|
@AssistedInject
|
||||||
MergeUtil(
|
MergeUtil(
|
||||||
@GerritServerConfig Config serverConfig,
|
@GerritServerConfig Config serverConfig,
|
||||||
Provider<ReviewDb> db,
|
|
||||||
IdentifiedUser.GenericFactory identifiedUserFactory,
|
IdentifiedUser.GenericFactory identifiedUserFactory,
|
||||||
UrlFormatter urlFormatter,
|
UrlFormatter urlFormatter,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
@@ -182,7 +178,6 @@ public class MergeUtil {
|
|||||||
@Assisted ProjectState project) {
|
@Assisted ProjectState project) {
|
||||||
this(
|
this(
|
||||||
serverConfig,
|
serverConfig,
|
||||||
db,
|
|
||||||
identifiedUserFactory,
|
identifiedUserFactory,
|
||||||
urlFormatter,
|
urlFormatter,
|
||||||
approvalsUtil,
|
approvalsUtil,
|
||||||
@@ -194,14 +189,12 @@ public class MergeUtil {
|
|||||||
@AssistedInject
|
@AssistedInject
|
||||||
MergeUtil(
|
MergeUtil(
|
||||||
@GerritServerConfig Config serverConfig,
|
@GerritServerConfig Config serverConfig,
|
||||||
Provider<ReviewDb> db,
|
|
||||||
IdentifiedUser.GenericFactory identifiedUserFactory,
|
IdentifiedUser.GenericFactory identifiedUserFactory,
|
||||||
UrlFormatter urlFormatter,
|
UrlFormatter urlFormatter,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
@Assisted ProjectState project,
|
@Assisted ProjectState project,
|
||||||
PluggableCommitMessageGenerator commitMessageGenerator,
|
PluggableCommitMessageGenerator commitMessageGenerator,
|
||||||
@Assisted boolean useContentMerge) {
|
@Assisted boolean useContentMerge) {
|
||||||
this.db = db;
|
|
||||||
this.identifiedUserFactory = identifiedUserFactory;
|
this.identifiedUserFactory = identifiedUserFactory;
|
||||||
this.urlFormatter = urlFormatter;
|
this.urlFormatter = urlFormatter;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
@@ -598,7 +591,7 @@ public class MergeUtil {
|
|||||||
|
|
||||||
private Iterable<PatchSetApproval> safeGetApprovals(ChangeNotes notes, PatchSet.Id psId) {
|
private Iterable<PatchSetApproval> safeGetApprovals(ChangeNotes notes, PatchSet.Id psId) {
|
||||||
try {
|
try {
|
||||||
return approvalsUtil.byPatchSet(db.get(), notes, psId, null, null);
|
return approvalsUtil.byPatchSet(notes, psId, null, null);
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
logger.atSevere().withCause(e).log("Can't read approval records for %s", psId);
|
logger.atSevere().withCause(e).log("Can't read approval records for %s", psId);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ReviewerSet;
|
import com.google.gerrit.server.ReviewerSet;
|
||||||
import com.google.gerrit.server.cache.CacheModule;
|
import com.google.gerrit.server.cache.CacheModule;
|
||||||
import com.google.gerrit.server.index.change.ChangeField;
|
import com.google.gerrit.server.index.change.ChangeField;
|
||||||
@@ -107,16 +106,15 @@ public class SearchingChangeCacheImpl implements GitReferenceUpdatedListener {
|
|||||||
* <p>Returned changes only include the {@code Change} object (with id, branch) and the reviewers.
|
* <p>Returned changes only include the {@code Change} object (with id, branch) and the reviewers.
|
||||||
* Additional stored fields are not loaded from the index.
|
* Additional stored fields are not loaded from the index.
|
||||||
*
|
*
|
||||||
* @param db database handle to populate missing change data (probably unused).
|
|
||||||
* @param project project to read.
|
* @param project project to read.
|
||||||
* @return list of known changes; empty if no changes.
|
* @return list of known changes; empty if no changes.
|
||||||
*/
|
*/
|
||||||
public List<ChangeData> getChangeData(ReviewDb db, Project.NameKey project) {
|
public List<ChangeData> getChangeData(Project.NameKey project) {
|
||||||
try {
|
try {
|
||||||
List<CachedChange> cached = cache.get(project);
|
List<CachedChange> cached = cache.get(project);
|
||||||
List<ChangeData> cds = new ArrayList<>(cached.size());
|
List<ChangeData> cds = new ArrayList<>(cached.size());
|
||||||
for (CachedChange cc : cached) {
|
for (CachedChange cc : cached) {
|
||||||
ChangeData cd = changeDataFactory.create(db, cc.change());
|
ChangeData cd = changeDataFactory.create(cc.change());
|
||||||
cd.setReviewers(cc.reviewers());
|
cd.setReviewers(cc.reviewers());
|
||||||
cds.add(cd);
|
cds.add(cd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
groups = prevPs != null ? prevPs.getGroups() : ImmutableList.<String>of();
|
groups = prevPs != null ? prevPs.getGroups() : ImmutableList.<String>of();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeData cd = changeDataFactory.create(ctx.getDb(), ctx.getNotes());
|
ChangeData cd = changeDataFactory.create(ctx.getNotes());
|
||||||
oldRecipients = getRecipientsFromReviewers(cd.reviewers());
|
oldRecipients = getRecipientsFromReviewers(cd.reviewers());
|
||||||
|
|
||||||
ChangeUpdate update = ctx.getUpdate(patchSetId);
|
ChangeUpdate update = ctx.getUpdate(patchSetId);
|
||||||
@@ -452,7 +452,6 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
if (!approvals.isEmpty()) {
|
if (!approvals.isEmpty()) {
|
||||||
for (PatchSetApproval a :
|
for (PatchSetApproval a :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
ctx.getDb(),
|
|
||||||
ctx.getNotes(),
|
ctx.getNotes(),
|
||||||
priorPatchSetId,
|
priorPatchSetId,
|
||||||
ctx.getAccountId(),
|
ctx.getAccountId(),
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.google.gerrit.reviewdb.client.Branch;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.AccountProperties;
|
import com.google.gerrit.server.account.AccountProperties;
|
||||||
import com.google.gerrit.server.config.AllProjectsName;
|
import com.google.gerrit.server.config.AllProjectsName;
|
||||||
@@ -46,7 +45,6 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
@@ -268,18 +266,15 @@ public class MergeValidators {
|
|||||||
AccountMergeValidator create();
|
AccountMergeValidator create();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<ReviewDb> dbProvider;
|
|
||||||
private final AllUsersName allUsersName;
|
private final AllUsersName allUsersName;
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final AccountValidator accountValidator;
|
private final AccountValidator accountValidator;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AccountMergeValidator(
|
public AccountMergeValidator(
|
||||||
Provider<ReviewDb> dbProvider,
|
|
||||||
AllUsersName allUsersName,
|
AllUsersName allUsersName,
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
AccountValidator accountValidator) {
|
AccountValidator accountValidator) {
|
||||||
this.dbProvider = dbProvider;
|
|
||||||
this.allUsersName = allUsersName;
|
this.allUsersName = allUsersName;
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.accountValidator = accountValidator;
|
this.accountValidator = accountValidator;
|
||||||
@@ -301,7 +296,7 @@ public class MergeValidators {
|
|||||||
|
|
||||||
ChangeData cd =
|
ChangeData cd =
|
||||||
changeDataFactory.create(
|
changeDataFactory.create(
|
||||||
dbProvider.get(), destProject.getProject().getNameKey(), patchSetId.getParentKey());
|
destProject.getProject().getNameKey(), patchSetId.getParentKey());
|
||||||
try {
|
try {
|
||||||
if (!cd.currentFilePaths().contains(AccountProperties.ACCOUNT_CONFIG)) {
|
if (!cd.currentFilePaths().contains(AccountProperties.ACCOUNT_CONFIG)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -224,20 +224,20 @@ public class AllChangesIndexer extends SiteIndexer<Change.Id, ChangeData, Change
|
|||||||
// It does mean that reindexing after invalidating the DiffSummary cache will be expensive,
|
// It does mean that reindexing after invalidating the DiffSummary cache will be expensive,
|
||||||
// but the goal is to invalidate that cache as infrequently as we possibly can. And besides,
|
// but the goal is to invalidate that cache as infrequently as we possibly can. And besides,
|
||||||
// we don't have concrete proof that improving packfile locality would help.
|
// we don't have concrete proof that improving packfile locality would help.
|
||||||
notesFactory.scan(repo, project).forEach(r -> index(db, r));
|
notesFactory.scan(repo, project).forEach(r -> index(r));
|
||||||
} catch (RepositoryNotFoundException rnfe) {
|
} catch (RepositoryNotFoundException rnfe) {
|
||||||
logger.atSevere().log(rnfe.getMessage());
|
logger.atSevere().log(rnfe.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void index(ReviewDb db, ChangeNotesResult r) {
|
private void index(ChangeNotesResult r) {
|
||||||
if (r.error().isPresent()) {
|
if (r.error().isPresent()) {
|
||||||
fail("Failed to read change " + r.id() + " for indexing", true, r.error().get());
|
fail("Failed to read change " + r.id() + " for indexing", true, r.error().get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
indexer.index(changeDataFactory.create(db, r.notes()));
|
indexer.index(changeDataFactory.create(r.notes()));
|
||||||
done.update(1);
|
done.update(1);
|
||||||
verboseWriter.println("Reindexed change " + r.id());
|
verboseWriter.println("Reindexed change " + r.id());
|
||||||
} catch (RejectedExecutionException e) {
|
} catch (RejectedExecutionException e) {
|
||||||
|
|||||||
@@ -223,22 +223,20 @@ public class ChangeIndexer {
|
|||||||
/**
|
/**
|
||||||
* Synchronously index a change.
|
* Synchronously index a change.
|
||||||
*
|
*
|
||||||
* @param db review database.
|
|
||||||
* @param change change to index.
|
* @param change change to index.
|
||||||
*/
|
*/
|
||||||
public void index(ReviewDb db, Change change) throws IOException {
|
public void index(Change change) throws IOException {
|
||||||
index(changeDataFactory.create(db, change));
|
index(changeDataFactory.create(change));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronously index a change.
|
* Synchronously index a change.
|
||||||
*
|
*
|
||||||
* @param db review database.
|
|
||||||
* @param project the project to which the change belongs.
|
* @param project the project to which the change belongs.
|
||||||
* @param changeId ID of the change to index.
|
* @param changeId ID of the change to index.
|
||||||
*/
|
*/
|
||||||
public void index(ReviewDb db, Project.NameKey project, Change.Id changeId) throws IOException {
|
public void index(Project.NameKey project, Change.Id changeId) throws IOException {
|
||||||
index(changeDataFactory.create(db, project, changeId));
|
index(changeDataFactory.create(project, changeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -369,7 +367,7 @@ public class ChangeIndexer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void callImpl(Provider<ReviewDb> db) throws Exception {
|
public Void callImpl(Provider<ReviewDb> db) throws Exception {
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), project, id);
|
ChangeData cd = changeDataFactory.create(project, id);
|
||||||
index(cd);
|
index(cd);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -415,7 +413,7 @@ public class ChangeIndexer {
|
|||||||
public Boolean callImpl(Provider<ReviewDb> db) throws Exception {
|
public Boolean callImpl(Provider<ReviewDb> db) throws Exception {
|
||||||
try {
|
try {
|
||||||
if (stalenessChecker.isStale(id)) {
|
if (stalenessChecker.isStale(id)) {
|
||||||
indexImpl(changeDataFactory.create(db.get(), project, id));
|
indexImpl(changeDataFactory.create(project, id));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import com.google.gerrit.reviewdb.client.Branch;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
import com.google.gerrit.server.account.AccountCache;
|
||||||
import com.google.gerrit.server.config.AllUsersName;
|
import com.google.gerrit.server.config.AllUsersName;
|
||||||
import com.google.gerrit.server.config.GerritServerConfig;
|
import com.google.gerrit.server.config.GerritServerConfig;
|
||||||
@@ -182,11 +181,10 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
|||||||
@Override
|
@Override
|
||||||
protected Void impl(RequestContext ctx) throws OrmException, IOException {
|
protected Void impl(RequestContext ctx) throws OrmException, IOException {
|
||||||
// Reload change, as some time may have passed since GetChanges.
|
// Reload change, as some time may have passed since GetChanges.
|
||||||
ReviewDb db = ctx.getReviewDbProvider().get();
|
|
||||||
try {
|
try {
|
||||||
Change c =
|
Change c =
|
||||||
notesFactory.createChecked(new Project.NameKey(event.getProjectName()), id).getChange();
|
notesFactory.createChecked(new Project.NameKey(event.getProjectName()), id).getChange();
|
||||||
indexerFactory.create(executor, indexes).index(db, c);
|
indexerFactory.create(executor, indexes).index(c);
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
indexerFactory.create(executor, indexes).delete(id);
|
indexerFactory.create(executor, indexes).delete(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.google.gerrit.reviewdb.client.Comment;
|
|||||||
import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
|
import com.google.gerrit.reviewdb.client.PatchLineComment.Status;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
@@ -84,6 +85,7 @@ import java.util.Set;
|
|||||||
public class MailProcessor {
|
public class MailProcessor {
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
|
private final Provider<ReviewDb> dbProvider;
|
||||||
private final Emails emails;
|
private final Emails emails;
|
||||||
private final InboundEmailRejectionSender.Factory emailRejectionSender;
|
private final InboundEmailRejectionSender.Factory emailRejectionSender;
|
||||||
private final RetryHelper retryHelper;
|
private final RetryHelper retryHelper;
|
||||||
@@ -102,6 +104,7 @@ public class MailProcessor {
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MailProcessor(
|
public MailProcessor(
|
||||||
|
Provider<ReviewDb> dbProvider,
|
||||||
Emails emails,
|
Emails emails,
|
||||||
InboundEmailRejectionSender.Factory emailRejectionSender,
|
InboundEmailRejectionSender.Factory emailRejectionSender,
|
||||||
RetryHelper retryHelper,
|
RetryHelper retryHelper,
|
||||||
@@ -117,6 +120,7 @@ public class MailProcessor {
|
|||||||
CommentAdded commentAdded,
|
CommentAdded commentAdded,
|
||||||
AccountCache accountCache,
|
AccountCache accountCache,
|
||||||
UrlFormatter urlFormatter) {
|
UrlFormatter urlFormatter) {
|
||||||
|
this.dbProvider = dbProvider;
|
||||||
this.emails = emails;
|
this.emails = emails;
|
||||||
this.emailRejectionSender = emailRejectionSender;
|
this.emailRejectionSender = emailRejectionSender;
|
||||||
this.retryHelper = retryHelper;
|
this.retryHelper = retryHelper;
|
||||||
@@ -259,7 +263,8 @@ public class MailProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Op o = new Op(new PatchSet.Id(cd.getId(), metadata.patchSet), parsedComments, message.id());
|
Op o = new Op(new PatchSet.Id(cd.getId(), metadata.patchSet), parsedComments, message.id());
|
||||||
BatchUpdate batchUpdate = buf.create(cd.db(), project, ctx.getUser(), TimeUtil.nowTs());
|
BatchUpdate batchUpdate =
|
||||||
|
buf.create(dbProvider.get(), project, ctx.getUser(), TimeUtil.nowTs());
|
||||||
batchUpdate.addOp(cd.getId(), o);
|
batchUpdate.addOp(cd.getId(), o);
|
||||||
batchUpdate.execute();
|
batchUpdate.execute();
|
||||||
}
|
}
|
||||||
@@ -329,12 +334,7 @@ public class MailProcessor {
|
|||||||
Map<String, Short> approvals = new HashMap<>();
|
Map<String, Short> approvals = new HashMap<>();
|
||||||
approvalsUtil
|
approvalsUtil
|
||||||
.byPatchSetUser(
|
.byPatchSetUser(
|
||||||
ctx.getDb(),
|
notes, psId, ctx.getAccountId(), ctx.getRevWalk(), ctx.getRepoView().getConfig())
|
||||||
notes,
|
|
||||||
psId,
|
|
||||||
ctx.getAccountId(),
|
|
||||||
ctx.getRevWalk(),
|
|
||||||
ctx.getRepoView().getConfig())
|
|
||||||
.forEach(a -> approvals.put(a.getLabel(), a.getValue()));
|
.forEach(a -> approvals.put(a.getLabel(), a.getValue()));
|
||||||
// Fire Gerrit event. Note that approvals can't be granted via email, so old and new approvals
|
// Fire Gerrit event. Note that approvals can't be granted via email, so old and new approvals
|
||||||
// are always the same here.
|
// are always the same here.
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
|
|
||||||
protected static ChangeData newChangeData(
|
protected static ChangeData newChangeData(
|
||||||
EmailArguments ea, Project.NameKey project, Change.Id id) {
|
EmailArguments ea, Project.NameKey project, Change.Id id) {
|
||||||
return ea.changeDataFactory.create(ea.db.get(), project, id);
|
return ea.changeDataFactory.create(project, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Change change;
|
protected final Change change;
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ public class MergedSender extends ReplyToChangeSender {
|
|||||||
Table<Account.Id, String, PatchSetApproval> pos = HashBasedTable.create();
|
Table<Account.Id, String, PatchSetApproval> pos = HashBasedTable.create();
|
||||||
Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create();
|
Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create();
|
||||||
for (PatchSetApproval ca :
|
for (PatchSetApproval ca :
|
||||||
args.approvalsUtil.byPatchSet(
|
args.approvalsUtil.byPatchSet(changeData.notes(), patchSet.getId(), null, null)) {
|
||||||
args.db.get(), changeData.notes(), patchSet.getId(), null, null)) {
|
|
||||||
LabelType lt = labelTypes.byLabel(ca.getLabelId());
|
LabelType lt = labelTypes.byLabel(ca.getLabelId());
|
||||||
if (lt == null) {
|
if (lt == null) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.permissions;
|
package com.google.gerrit.server.permissions;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
|
||||||
import static com.google.gerrit.server.permissions.DefaultPermissionMappings.labelPermissionName;
|
import static com.google.gerrit.server.permissions.DefaultPermissionMappings.labelPermissionName;
|
||||||
import static com.google.gerrit.server.permissions.LabelPermission.ForUser.ON_BEHALF_OF;
|
import static com.google.gerrit.server.permissions.LabelPermission.ForUser.ON_BEHALF_OF;
|
||||||
|
|
||||||
@@ -35,7 +34,6 @@ import com.google.gerrit.server.permissions.PermissionBackend.ForChange;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -76,8 +74,8 @@ class ChangeControl {
|
|||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
ForChange asForChange(@Nullable ChangeData cd, @Nullable Provider<ReviewDb> db) {
|
ForChange asForChange(@Nullable ChangeData cd) {
|
||||||
return new ForChangeImpl(cd, db);
|
return new ForChangeImpl(cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CurrentUser getUser() {
|
private CurrentUser getUser() {
|
||||||
@@ -93,8 +91,8 @@ class ChangeControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Can this user see this change? */
|
/** Can this user see this change? */
|
||||||
private boolean isVisible(ReviewDb db, @Nullable ChangeData cd) throws OrmException {
|
private boolean isVisible(@Nullable ChangeData cd) throws OrmException {
|
||||||
if (getChange().isPrivate() && !isPrivateVisible(db, cd)) {
|
if (getChange().isPrivate() && !isPrivateVisible(cd)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return refControl.isVisible();
|
return refControl.isVisible();
|
||||||
@@ -157,9 +155,9 @@ class ChangeControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Is this user a reviewer for the change? */
|
/** Is this user a reviewer for the change? */
|
||||||
private boolean isReviewer(ReviewDb db, @Nullable ChangeData cd) throws OrmException {
|
private boolean isReviewer(@Nullable ChangeData cd) throws OrmException {
|
||||||
if (getUser().isIdentifiedUser()) {
|
if (getUser().isIdentifiedUser()) {
|
||||||
cd = cd != null ? cd : changeDataFactory.create(db, notes);
|
cd = cd != null ? cd : changeDataFactory.create(notes);
|
||||||
Collection<Account.Id> results = cd.reviewers().all();
|
Collection<Account.Id> results = cd.reviewers().all();
|
||||||
return results.contains(getUser().getAccountId());
|
return results.contains(getUser().getAccountId());
|
||||||
}
|
}
|
||||||
@@ -207,9 +205,9 @@ class ChangeControl {
|
|||||||
|| getProjectControl().isAdmin();
|
|| getProjectControl().isAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPrivateVisible(ReviewDb db, ChangeData cd) throws OrmException {
|
private boolean isPrivateVisible(ChangeData cd) throws OrmException {
|
||||||
return isOwner()
|
return isOwner()
|
||||||
|| isReviewer(db, cd)
|
|| isReviewer(cd)
|
||||||
|| refControl.canPerform(Permission.VIEW_PRIVATE_CHANGES)
|
|| refControl.canPerform(Permission.VIEW_PRIVATE_CHANGES)
|
||||||
|| getUser().isInternalUser();
|
|| getUser().isInternalUser();
|
||||||
}
|
}
|
||||||
@@ -219,26 +217,20 @@ class ChangeControl {
|
|||||||
private Map<String, PermissionRange> labels;
|
private Map<String, PermissionRange> labels;
|
||||||
private String resourcePath;
|
private String resourcePath;
|
||||||
|
|
||||||
ForChangeImpl(@Nullable ChangeData cd, @Nullable Provider<ReviewDb> db) {
|
ForChangeImpl(@Nullable ChangeData cd) {
|
||||||
this.cd = cd;
|
this.cd = cd;
|
||||||
this.db = db;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReviewDb db() {
|
private ReviewDb db() {
|
||||||
if (db != null) {
|
if (db != null) {
|
||||||
return db.get();
|
return db.get();
|
||||||
} else if (cd != null) {
|
|
||||||
return cd.db();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeData changeData() {
|
private ChangeData changeData() {
|
||||||
if (cd == null) {
|
if (cd == null) {
|
||||||
ReviewDb reviewDb = db();
|
cd = changeDataFactory.create(notes);
|
||||||
checkState(reviewDb != null, "need ReviewDb");
|
|
||||||
cd = changeDataFactory.create(reviewDb, notes);
|
|
||||||
}
|
}
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
@@ -294,7 +286,7 @@ class ChangeControl {
|
|||||||
try {
|
try {
|
||||||
switch (perm) {
|
switch (perm) {
|
||||||
case READ:
|
case READ:
|
||||||
return isVisible(db(), changeData());
|
return isVisible(changeData());
|
||||||
case ABANDON:
|
case ABANDON:
|
||||||
return canAbandon();
|
return canAbandon();
|
||||||
case DELETE:
|
case DELETE:
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ class DefaultRefFilter {
|
|||||||
private final TagCache tagCache;
|
private final TagCache tagCache;
|
||||||
private final ChangeNotes.Factory changeNotesFactory;
|
private final ChangeNotes.Factory changeNotesFactory;
|
||||||
@Nullable private final SearchingChangeCacheImpl changeCache;
|
@Nullable private final SearchingChangeCacheImpl changeCache;
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final GroupCache groupCache;
|
private final GroupCache groupCache;
|
||||||
private final PermissionBackend permissionBackend;
|
private final PermissionBackend permissionBackend;
|
||||||
private final ProjectControl projectControl;
|
private final ProjectControl projectControl;
|
||||||
@@ -103,7 +102,6 @@ class DefaultRefFilter {
|
|||||||
this.tagCache = tagCache;
|
this.tagCache = tagCache;
|
||||||
this.changeNotesFactory = changeNotesFactory;
|
this.changeNotesFactory = changeNotesFactory;
|
||||||
this.changeCache = changeCache;
|
this.changeCache = changeCache;
|
||||||
this.db = db;
|
|
||||||
this.groupCache = groupCache;
|
this.groupCache = groupCache;
|
||||||
this.permissionBackend = permissionBackend;
|
this.permissionBackend = permissionBackend;
|
||||||
this.skipFullRefEvaluationIfAllRefsAreVisible =
|
this.skipFullRefEvaluationIfAllRefsAreVisible =
|
||||||
@@ -334,7 +332,7 @@ class DefaultRefFilter {
|
|||||||
Project.NameKey project = projectState.getNameKey();
|
Project.NameKey project = projectState.getNameKey();
|
||||||
try {
|
try {
|
||||||
Map<Change.Id, Branch.NameKey> visibleChanges = new HashMap<>();
|
Map<Change.Id, Branch.NameKey> visibleChanges = new HashMap<>();
|
||||||
for (ChangeData cd : changeCache.getChangeData(db.get(), project)) {
|
for (ChangeData cd : changeCache.getChangeData(project)) {
|
||||||
ChangeNotes notes = changeNotesFactory.createFromIndexedChange(cd.change());
|
ChangeNotes notes = changeNotesFactory.createFromIndexedChange(cd.change());
|
||||||
if (!projectState.statePermitsRead()) {
|
if (!projectState.statePermitsRead()) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import com.google.gerrit.server.permissions.PermissionBackend.ForRef;
|
|||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gerrit.server.util.MagicBranch;
|
import com.google.gerrit.server.util.MagicBranch;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.util.Providers;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -442,7 +441,7 @@ class RefControl {
|
|||||||
public ForChange change(ChangeData cd) {
|
public ForChange change(ChangeData cd) {
|
||||||
try {
|
try {
|
||||||
// TODO(hiesel) Force callers to call database() and use db instead of cd.db()
|
// TODO(hiesel) Force callers to call database() and use db instead of cd.db()
|
||||||
return getProjectControl().controlFor(cd.change()).asForChange(cd, Providers.of(cd.db()));
|
return getProjectControl().controlFor(cd.change()).asForChange(cd);
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
return FailedPermissionBackend.change("unavailable", e);
|
return FailedPermissionBackend.change("unavailable", e);
|
||||||
}
|
}
|
||||||
@@ -457,12 +456,12 @@ class RefControl {
|
|||||||
"expected change in project %s, not %s",
|
"expected change in project %s, not %s",
|
||||||
project,
|
project,
|
||||||
change.getProject());
|
change.getProject());
|
||||||
return getProjectControl().controlFor(notes).asForChange(null, db);
|
return getProjectControl().controlFor(notes).asForChange(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForChange indexedChange(ChangeData cd, ChangeNotes notes) {
|
public ForChange indexedChange(ChangeData cd, ChangeNotes notes) {
|
||||||
return getProjectControl().controlFor(notes).asForChange(cd, db);
|
return getProjectControl().controlFor(notes).asForChange(cd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.ChangeMessagesUtil;
|
import com.google.gerrit.server.ChangeMessagesUtil;
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
@@ -196,23 +195,22 @@ public class ChangeData {
|
|||||||
this.assistedFactory = assistedFactory;
|
this.assistedFactory = assistedFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeData create(ReviewDb db, Project.NameKey project, Change.Id id) {
|
public ChangeData create(Project.NameKey project, Change.Id id) {
|
||||||
return assistedFactory.create(db, project, id, null, null);
|
return assistedFactory.create(project, id, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeData create(ReviewDb db, Change change) {
|
public ChangeData create(Change change) {
|
||||||
return assistedFactory.create(db, change.getProject(), change.getId(), change, null);
|
return assistedFactory.create(change.getProject(), change.getId(), change, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChangeData create(ReviewDb db, ChangeNotes notes) {
|
public ChangeData create(ChangeNotes notes) {
|
||||||
return assistedFactory.create(
|
return assistedFactory.create(
|
||||||
db, notes.getChange().getProject(), notes.getChangeId(), notes.getChange(), notes);
|
notes.getChange().getProject(), notes.getChangeId(), notes.getChange(), notes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface AssistedFactory {
|
public interface AssistedFactory {
|
||||||
ChangeData create(
|
ChangeData create(
|
||||||
ReviewDb db,
|
|
||||||
Project.NameKey project,
|
Project.NameKey project,
|
||||||
Change.Id id,
|
Change.Id id,
|
||||||
@Nullable Change change,
|
@Nullable Change change,
|
||||||
@@ -233,7 +231,7 @@ public class ChangeData {
|
|||||||
ChangeData cd =
|
ChangeData cd =
|
||||||
new ChangeData(
|
new ChangeData(
|
||||||
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null, null, project, id, null, null);
|
null, project, id, null, null);
|
||||||
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
|
cd.currentPatchSet = new PatchSet(new PatchSet.Id(id, currentPatchSetId));
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
@@ -256,7 +254,6 @@ public class ChangeData {
|
|||||||
private final SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory;
|
private final SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory;
|
||||||
|
|
||||||
// Required assisted injected fields.
|
// Required assisted injected fields.
|
||||||
private final ReviewDb db;
|
|
||||||
private final Project.NameKey project;
|
private final Project.NameKey project;
|
||||||
private final Change.Id legacyId;
|
private final Change.Id legacyId;
|
||||||
|
|
||||||
@@ -322,7 +319,6 @@ public class ChangeData {
|
|||||||
TrackingFooters trackingFooters,
|
TrackingFooters trackingFooters,
|
||||||
PureRevert pureRevert,
|
PureRevert pureRevert,
|
||||||
SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory,
|
SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory,
|
||||||
@Assisted ReviewDb db,
|
|
||||||
@Assisted Project.NameKey project,
|
@Assisted Project.NameKey project,
|
||||||
@Assisted Change.Id id,
|
@Assisted Change.Id id,
|
||||||
@Assisted @Nullable Change change,
|
@Assisted @Nullable Change change,
|
||||||
@@ -343,11 +339,6 @@ public class ChangeData {
|
|||||||
this.pureRevert = pureRevert;
|
this.pureRevert = pureRevert;
|
||||||
this.submitRuleEvaluatorFactory = submitRuleEvaluatorFactory;
|
this.submitRuleEvaluatorFactory = submitRuleEvaluatorFactory;
|
||||||
|
|
||||||
// May be null in tests when created via createForTest above, in which case lazy-loading will
|
|
||||||
// intentionally fail with NPE. Still not marked @Nullable in the constructor, to force callers
|
|
||||||
// using Guice to pass a non-null value.
|
|
||||||
this.db = db;
|
|
||||||
|
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.legacyId = id;
|
this.legacyId = id;
|
||||||
|
|
||||||
@@ -367,10 +358,6 @@ public class ChangeData {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReviewDb db() {
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AllUsersName getAllUsersNameForIndexing() {
|
public AllUsersName getAllUsersNameForIndexing() {
|
||||||
return allUsersName;
|
return allUsersName;
|
||||||
}
|
}
|
||||||
@@ -536,7 +523,7 @@ public class ChangeData {
|
|||||||
try {
|
try {
|
||||||
currentApprovals =
|
currentApprovals =
|
||||||
ImmutableList.copyOf(
|
ImmutableList.copyOf(
|
||||||
approvalsUtil.byPatchSet(db, notes(), c.currentPatchSetId(), null, null));
|
approvalsUtil.byPatchSet(notes(), c.currentPatchSetId(), null, null));
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
if (e.getCause() instanceof NoSuchChangeException) {
|
if (e.getCause() instanceof NoSuchChangeException) {
|
||||||
currentApprovals = Collections.emptyList();
|
currentApprovals = Collections.emptyList();
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class ConflictsPredicate {
|
|||||||
ChangeData cd;
|
ChangeData cd;
|
||||||
List<String> files;
|
List<String> files;
|
||||||
try {
|
try {
|
||||||
cd = args.changeDataFactory.create(args.db.get(), c);
|
cd = args.changeDataFactory.create(c);
|
||||||
files = cd.currentFilePaths();
|
files = cd.currentFilePaths();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new OrmException(e);
|
throw new OrmException(e);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import com.google.gerrit.reviewdb.client.Branch;
|
|||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
import com.google.gerrit.server.index.change.ChangeIndexCollection;
|
||||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@@ -168,11 +167,10 @@ public class InternalChangeQuery extends InternalQuery<ChangeData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<ChangeData> byCommitsOnBranchNotMerged(
|
public Iterable<ChangeData> byCommitsOnBranchNotMerged(
|
||||||
Repository repo, ReviewDb db, Branch.NameKey branch, Collection<String> hashes)
|
Repository repo, Branch.NameKey branch, Collection<String> hashes)
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
return byCommitsOnBranchNotMerged(
|
return byCommitsOnBranchNotMerged(
|
||||||
repo,
|
repo,
|
||||||
db,
|
|
||||||
branch,
|
branch,
|
||||||
hashes,
|
hashes,
|
||||||
// Account for all commit predicates plus ref, project, status.
|
// Account for all commit predicates plus ref, project, status.
|
||||||
@@ -181,20 +179,16 @@ public class InternalChangeQuery extends InternalQuery<ChangeData> {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Iterable<ChangeData> byCommitsOnBranchNotMerged(
|
Iterable<ChangeData> byCommitsOnBranchNotMerged(
|
||||||
Repository repo,
|
Repository repo, Branch.NameKey branch, Collection<String> hashes, int indexLimit)
|
||||||
ReviewDb db,
|
|
||||||
Branch.NameKey branch,
|
|
||||||
Collection<String> hashes,
|
|
||||||
int indexLimit)
|
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
if (hashes.size() > indexLimit) {
|
if (hashes.size() > indexLimit) {
|
||||||
return byCommitsOnBranchNotMergedFromDatabase(repo, db, branch, hashes);
|
return byCommitsOnBranchNotMergedFromDatabase(repo, branch, hashes);
|
||||||
}
|
}
|
||||||
return byCommitsOnBranchNotMergedFromIndex(branch, hashes);
|
return byCommitsOnBranchNotMergedFromIndex(branch, hashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<ChangeData> byCommitsOnBranchNotMergedFromDatabase(
|
private Iterable<ChangeData> byCommitsOnBranchNotMergedFromDatabase(
|
||||||
Repository repo, ReviewDb db, Branch.NameKey branch, Collection<String> hashes)
|
Repository repo, Branch.NameKey branch, Collection<String> hashes)
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
Set<Change.Id> changeIds = Sets.newHashSetWithExpectedSize(hashes.size());
|
Set<Change.Id> changeIds = Sets.newHashSetWithExpectedSize(hashes.size());
|
||||||
String lastPrefix = null;
|
String lastPrefix = null;
|
||||||
@@ -221,7 +215,7 @@ public class InternalChangeQuery extends InternalQuery<ChangeData> {
|
|||||||
Change c = cn.getChange();
|
Change c = cn.getChange();
|
||||||
return c.getDest().equals(branch) && c.getStatus() != Change.Status.MERGED;
|
return c.getDest().equals(branch) && c.getStatus() != Change.Status.MERGED;
|
||||||
});
|
});
|
||||||
return Lists.transform(notes, n -> changeDataFactory.create(db, n));
|
return Lists.transform(notes, n -> changeDataFactory.create(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<ChangeData> byCommitsOnBranchNotMergedFromIndex(
|
private Iterable<ChangeData> byCommitsOnBranchNotMergedFromIndex(
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ public class OutputStreamQuery {
|
|||||||
ChangeData d, Map<Project.NameKey, Repository> repos, Map<Project.NameKey, RevWalk> revWalks)
|
ChangeData d, Map<Project.NameKey, Repository> repos, Map<Project.NameKey, RevWalk> revWalks)
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
LabelTypes labelTypes = d.getLabelTypes();
|
LabelTypes labelTypes = d.getLabelTypes();
|
||||||
ChangeAttribute c = eventFactory.asChangeAttribute(db, d.change(), d.notes());
|
ChangeAttribute c = eventFactory.asChangeAttribute(d.change(), d.notes());
|
||||||
eventFactory.extend(c, d.change());
|
eventFactory.extend(c, d.change());
|
||||||
|
|
||||||
if (!trackingFooters.isEmpty()) {
|
if (!trackingFooters.isEmpty()) {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class DeleteDraftComments
|
|||||||
result.change =
|
result.change =
|
||||||
changeJsonFactory
|
changeJsonFactory
|
||||||
.create(ListChangesOption.SKIP_MERGEABLE)
|
.create(ListChangesOption.SKIP_MERGEABLE)
|
||||||
.format(changeDataFactory.create(ctx.getDb(), ctx.getNotes()));
|
.format(changeDataFactory.create(ctx.getNotes()));
|
||||||
result.deleted = comments.build();
|
result.deleted = comments.build();
|
||||||
}
|
}
|
||||||
return dirty;
|
return dirty;
|
||||||
|
|||||||
@@ -178,12 +178,7 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
|||||||
|
|
||||||
for (PatchSetApproval a :
|
for (PatchSetApproval a :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
ctx.getDb(),
|
ctx.getNotes(), psId, accountId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) {
|
||||||
ctx.getNotes(),
|
|
||||||
psId,
|
|
||||||
accountId,
|
|
||||||
ctx.getRevWalk(),
|
|
||||||
ctx.getRepoView().getConfig())) {
|
|
||||||
if (labelTypes.byLabel(a.getLabelId()) == null) {
|
if (labelTypes.byLabel(a.getLabelId()) == null) {
|
||||||
continue; // Ignore undefined labels.
|
continue; // Ignore undefined labels.
|
||||||
} else if (!a.getLabel().equals(label)) {
|
} else if (!a.getLabel().equals(label)) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.restapi.change;
|
|||||||
import com.google.gerrit.extensions.common.Input;
|
import com.google.gerrit.extensions.common.Input;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.Response;
|
import com.google.gerrit.extensions.restapi.Response;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.index.change.ChangeIndexer;
|
import com.google.gerrit.server.index.change.ChangeIndexer;
|
||||||
import com.google.gerrit.server.permissions.GlobalPermission;
|
import com.google.gerrit.server.permissions.GlobalPermission;
|
||||||
@@ -28,25 +27,17 @@ import com.google.gerrit.server.update.RetryHelper;
|
|||||||
import com.google.gerrit.server.update.RetryingRestModifyView;
|
import com.google.gerrit.server.update.RetryingRestModifyView;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class Index extends RetryingRestModifyView<ChangeResource, Input, Response<?>> {
|
public class Index extends RetryingRestModifyView<ChangeResource, Input, Response<?>> {
|
||||||
|
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final PermissionBackend permissionBackend;
|
private final PermissionBackend permissionBackend;
|
||||||
private final ChangeIndexer indexer;
|
private final ChangeIndexer indexer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Index(
|
Index(RetryHelper retryHelper, PermissionBackend permissionBackend, ChangeIndexer indexer) {
|
||||||
Provider<ReviewDb> db,
|
|
||||||
RetryHelper retryHelper,
|
|
||||||
PermissionBackend permissionBackend,
|
|
||||||
ChangeIndexer indexer) {
|
|
||||||
super(retryHelper);
|
super(retryHelper);
|
||||||
this.db = db;
|
|
||||||
this.permissionBackend = permissionBackend;
|
this.permissionBackend = permissionBackend;
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
}
|
}
|
||||||
@@ -56,7 +47,7 @@ public class Index extends RetryingRestModifyView<ChangeResource, Input, Respons
|
|||||||
BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input)
|
BatchUpdate.Factory updateFactory, ChangeResource rsrc, Input input)
|
||||||
throws IOException, AuthException, OrmException, PermissionBackendException {
|
throws IOException, AuthException, OrmException, PermissionBackendException {
|
||||||
permissionBackend.currentUser().check(GlobalPermission.MAINTAIN_SERVER);
|
permissionBackend.currentUser().check(GlobalPermission.MAINTAIN_SERVER);
|
||||||
indexer.index(db.get(), rsrc.getChange());
|
indexer.index(rsrc.getChange());
|
||||||
return Response.none();
|
return Response.none();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.restapi.change;
|
|||||||
import com.google.gerrit.extensions.common.CommentInfo;
|
import com.google.gerrit.extensions.common.CommentInfo;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -31,18 +30,15 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ListChangeComments implements RestReadView<ChangeResource> {
|
public class ListChangeComments implements RestReadView<ChangeResource> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Provider<CommentJson> commentJson;
|
private final Provider<CommentJson> commentJson;
|
||||||
private final CommentsUtil commentsUtil;
|
private final CommentsUtil commentsUtil;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListChangeComments(
|
ListChangeComments(
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
Provider<CommentJson> commentJson,
|
Provider<CommentJson> commentJson,
|
||||||
CommentsUtil commentsUtil) {
|
CommentsUtil commentsUtil) {
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.commentJson = commentJson;
|
this.commentJson = commentJson;
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
@@ -51,7 +47,7 @@ public class ListChangeComments implements RestReadView<ChangeResource> {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, List<CommentInfo>> apply(ChangeResource rsrc)
|
public Map<String, List<CommentInfo>> apply(ChangeResource rsrc)
|
||||||
throws AuthException, OrmException, PermissionBackendException {
|
throws AuthException, OrmException, PermissionBackendException {
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
return commentJson
|
return commentJson
|
||||||
.get()
|
.get()
|
||||||
.setFillAccounts(true)
|
.setFillAccounts(true)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import com.google.gerrit.extensions.common.CommentInfo;
|
|||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.client.Comment;
|
import com.google.gerrit.reviewdb.client.Comment;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -32,18 +31,15 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ListChangeDrafts implements RestReadView<ChangeResource> {
|
public class ListChangeDrafts implements RestReadView<ChangeResource> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Provider<CommentJson> commentJson;
|
private final Provider<CommentJson> commentJson;
|
||||||
private final CommentsUtil commentsUtil;
|
private final CommentsUtil commentsUtil;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListChangeDrafts(
|
ListChangeDrafts(
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
Provider<CommentJson> commentJson,
|
Provider<CommentJson> commentJson,
|
||||||
CommentsUtil commentsUtil) {
|
CommentsUtil commentsUtil) {
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.commentJson = commentJson;
|
this.commentJson = commentJson;
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
@@ -55,7 +51,7 @@ public class ListChangeDrafts implements RestReadView<ChangeResource> {
|
|||||||
if (!rsrc.getUser().isIdentifiedUser()) {
|
if (!rsrc.getUser().isIdentifiedUser()) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
}
|
}
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
List<Comment> drafts =
|
List<Comment> drafts =
|
||||||
commentsUtil.draftByChangeAuthor(cd.notes(), rsrc.getUser().getAccountId());
|
commentsUtil.draftByChangeAuthor(cd.notes(), rsrc.getUser().getAccountId());
|
||||||
return commentJson
|
return commentJson
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.google.gerrit.server.restapi.change;
|
|||||||
import com.google.gerrit.extensions.common.RobotCommentInfo;
|
import com.google.gerrit.extensions.common.RobotCommentInfo;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.CommentsUtil;
|
import com.google.gerrit.server.CommentsUtil;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -29,18 +28,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ListChangeRobotComments implements RestReadView<ChangeResource> {
|
public class ListChangeRobotComments implements RestReadView<ChangeResource> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final Provider<CommentJson> commentJson;
|
private final Provider<CommentJson> commentJson;
|
||||||
private final CommentsUtil commentsUtil;
|
private final CommentsUtil commentsUtil;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListChangeRobotComments(
|
ListChangeRobotComments(
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
Provider<CommentJson> commentJson,
|
Provider<CommentJson> commentJson,
|
||||||
CommentsUtil commentsUtil) {
|
CommentsUtil commentsUtil) {
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.commentJson = commentJson;
|
this.commentJson = commentJson;
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
@@ -49,7 +45,7 @@ public class ListChangeRobotComments implements RestReadView<ChangeResource> {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, List<RobotCommentInfo>> apply(ChangeResource rsrc)
|
public Map<String, List<RobotCommentInfo>> apply(ChangeResource rsrc)
|
||||||
throws AuthException, OrmException, PermissionBackendException {
|
throws AuthException, OrmException, PermissionBackendException {
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
return commentJson
|
return commentJson
|
||||||
.get()
|
.get()
|
||||||
.setFillAccounts(true)
|
.setFillAccounts(true)
|
||||||
|
|||||||
@@ -20,14 +20,12 @@ import com.google.gerrit.extensions.restapi.Response;
|
|||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.webui.UiAction;
|
import com.google.gerrit.extensions.webui.UiAction;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.StarredChangesUtil;
|
import com.google.gerrit.server.StarredChangesUtil;
|
||||||
import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException;
|
import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -35,16 +33,11 @@ public class MarkAsReviewed
|
|||||||
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
private final Provider<ReviewDb> dbProvider;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final StarredChangesUtil stars;
|
private final StarredChangesUtil stars;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MarkAsReviewed(
|
MarkAsReviewed(ChangeData.Factory changeDataFactory, StarredChangesUtil stars) {
|
||||||
Provider<ReviewDb> dbProvider,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
|
||||||
StarredChangesUtil stars) {
|
|
||||||
this.dbProvider = dbProvider;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.stars = stars;
|
this.stars = stars;
|
||||||
}
|
}
|
||||||
@@ -67,7 +60,7 @@ public class MarkAsReviewed
|
|||||||
private boolean isReviewed(ChangeResource rsrc) {
|
private boolean isReviewed(ChangeResource rsrc) {
|
||||||
try {
|
try {
|
||||||
return changeDataFactory
|
return changeDataFactory
|
||||||
.create(dbProvider.get(), rsrc.getNotes())
|
.create(rsrc.getNotes())
|
||||||
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ import com.google.gerrit.extensions.common.Input;
|
|||||||
import com.google.gerrit.extensions.restapi.Response;
|
import com.google.gerrit.extensions.restapi.Response;
|
||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.webui.UiAction;
|
import com.google.gerrit.extensions.webui.UiAction;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.StarredChangesUtil;
|
import com.google.gerrit.server.StarredChangesUtil;
|
||||||
import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException;
|
import com.google.gerrit.server.StarredChangesUtil.IllegalLabelException;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.query.change.ChangeData;
|
import com.google.gerrit.server.query.change.ChangeData;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -34,16 +32,11 @@ public class MarkAsUnreviewed
|
|||||||
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
|
|
||||||
private final Provider<ReviewDb> dbProvider;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final StarredChangesUtil stars;
|
private final StarredChangesUtil stars;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MarkAsUnreviewed(
|
MarkAsUnreviewed(ChangeData.Factory changeDataFactory, StarredChangesUtil stars) {
|
||||||
Provider<ReviewDb> dbProvider,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
|
||||||
StarredChangesUtil stars) {
|
|
||||||
this.dbProvider = dbProvider;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.stars = stars;
|
this.stars = stars;
|
||||||
}
|
}
|
||||||
@@ -66,7 +59,7 @@ public class MarkAsUnreviewed
|
|||||||
private boolean isReviewed(ChangeResource rsrc) {
|
private boolean isReviewed(ChangeResource rsrc) {
|
||||||
try {
|
try {
|
||||||
return changeDataFactory
|
return changeDataFactory
|
||||||
.create(dbProvider.get(), rsrc.getNotes())
|
.create(rsrc.getNotes())
|
||||||
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class Mergeable implements RestReadView<RevisionResource> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), resource.getNotes());
|
ChangeData cd = changeDataFactory.create(resource.getNotes());
|
||||||
result.submitType = getSubmitType(cd);
|
result.submitType = getSubmitType(cd);
|
||||||
|
|
||||||
try (Repository git = gitManager.openRepository(change.getProject())) {
|
try (Repository git = gitManager.openRepository(change.getProject())) {
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
|
|||||||
List<PatchSetApproval> approvals = new ArrayList<>();
|
List<PatchSetApproval> approvals = new ArrayList<>();
|
||||||
for (PatchSetApproval psa :
|
for (PatchSetApproval psa :
|
||||||
approvalsUtil.byPatchSet(
|
approvalsUtil.byPatchSet(
|
||||||
ctx.getDb(), ctx.getNotes(), psId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) {
|
ctx.getNotes(), psId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) {
|
||||||
ProjectState projectState = projectCache.checkedGet(project);
|
ProjectState projectState = projectCache.checkedGet(project);
|
||||||
LabelType type = projectState.getLabelTypes(ctx.getNotes()).byLabel(psa.getLabelId());
|
LabelType type = projectState.getLabelTypes(ctx.getNotes()).byLabel(psa.getLabelId());
|
||||||
// Only keep veto votes, defined as votes where:
|
// Only keep veto votes, defined as votes where:
|
||||||
|
|||||||
@@ -380,8 +380,7 @@ public class PostReview
|
|||||||
bu.execute();
|
bu.execute();
|
||||||
|
|
||||||
// Re-read change to take into account results of the update.
|
// Re-read change to take into account results of the update.
|
||||||
ChangeData cd =
|
ChangeData cd = changeDataFactory.create(revision.getProject(), revision.getChange().getId());
|
||||||
changeDataFactory.create(db.get(), revision.getProject(), revision.getChange().getId());
|
|
||||||
for (ReviewerAddition reviewerResult : reviewerResults) {
|
for (ReviewerAddition reviewerResult : reviewerResults) {
|
||||||
reviewerResult.gatherResults(cd);
|
reviewerResult.gatherResults(cd);
|
||||||
}
|
}
|
||||||
@@ -1146,7 +1145,7 @@ public class PostReview
|
|||||||
if (ctx.getAccountId().equals(ctx.getChange().getOwner())) {
|
if (ctx.getAccountId().equals(ctx.getChange().getOwner())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), ctx.getNotes());
|
ChangeData cd = changeDataFactory.create(ctx.getNotes());
|
||||||
ReviewerSet reviewers = cd.reviewers();
|
ReviewerSet reviewers = cd.reviewers();
|
||||||
if (reviewers.byState(REVIEWER).contains(ctx.getAccountId())) {
|
if (reviewers.byState(REVIEWER).contains(ctx.getAccountId())) {
|
||||||
return true;
|
return true;
|
||||||
@@ -1357,7 +1356,6 @@ public class PostReview
|
|||||||
|
|
||||||
for (PatchSetApproval a :
|
for (PatchSetApproval a :
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
ctx.getDb(),
|
|
||||||
ctx.getNotes(),
|
ctx.getNotes(),
|
||||||
psId,
|
psId,
|
||||||
user.getAccountId(),
|
user.getAccountId(),
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ public class PostReviewers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-read change to take into account results of the update.
|
// Re-read change to take into account results of the update.
|
||||||
addition.gatherResults(
|
addition.gatherResults(changeDataFactory.create(rsrc.getProject(), rsrc.getId()));
|
||||||
changeDataFactory.create(dbProvider.get(), rsrc.getProject(), rsrc.getId()));
|
|
||||||
return addition.result;
|
return addition.result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ public class Submit
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReviewDb db = dbProvider.get();
|
ReviewDb db = dbProvider.get();
|
||||||
ChangeData cd = changeDataFactory.create(db, resource.getNotes());
|
ChangeData cd = changeDataFactory.create(resource.getNotes());
|
||||||
try {
|
try {
|
||||||
MergeOp.checkSubmitRule(cd, false);
|
MergeOp.checkSubmitRule(cd, false);
|
||||||
} catch (ResourceConflictException e) {
|
} catch (ResourceConflictException e) {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.google.gerrit.extensions.common.TestSubmitRuleInput.Filters;
|
|||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.account.AccountLoader;
|
import com.google.gerrit.server.account.AccountLoader;
|
||||||
import com.google.gerrit.server.change.RevisionResource;
|
import com.google.gerrit.server.change.RevisionResource;
|
||||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||||
@@ -38,13 +37,11 @@ import com.google.gerrit.server.rules.PrologRule;
|
|||||||
import com.google.gerrit.server.rules.RulesCache;
|
import com.google.gerrit.server.rules.RulesCache;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
public class TestSubmitRule implements RestModifyView<RevisionResource, TestSubmitRuleInput> {
|
public class TestSubmitRule implements RestModifyView<RevisionResource, TestSubmitRuleInput> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final RulesCache rules;
|
private final RulesCache rules;
|
||||||
private final AccountLoader.Factory accountInfoFactory;
|
private final AccountLoader.Factory accountInfoFactory;
|
||||||
@@ -57,14 +54,12 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, TestSubm
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TestSubmitRule(
|
TestSubmitRule(
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
RulesCache rules,
|
RulesCache rules,
|
||||||
AccountLoader.Factory infoFactory,
|
AccountLoader.Factory infoFactory,
|
||||||
ProjectCache projectCache,
|
ProjectCache projectCache,
|
||||||
DefaultSubmitRule defaultSubmitRule,
|
DefaultSubmitRule defaultSubmitRule,
|
||||||
PrologRule prologRule) {
|
PrologRule prologRule) {
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
this.accountInfoFactory = infoFactory;
|
this.accountInfoFactory = infoFactory;
|
||||||
@@ -95,7 +90,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, TestSubm
|
|||||||
if (projectState == null) {
|
if (projectState == null) {
|
||||||
throw new BadRequestException("project not found");
|
throw new BadRequestException("project not found");
|
||||||
}
|
}
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
List<SubmitRecord> records;
|
List<SubmitRecord> records;
|
||||||
if (projectState.hasPrologRules() || input.rule != null) {
|
if (projectState.hasPrologRules() || input.rule != null) {
|
||||||
records = ImmutableList.copyOf(prologRule.evaluate(cd, opts));
|
records = ImmutableList.copyOf(prologRule.evaluate(cd, opts));
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
|||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.change.RevisionResource;
|
import com.google.gerrit.server.change.RevisionResource;
|
||||||
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||||
import com.google.gerrit.server.project.SubmitRuleOptions;
|
import com.google.gerrit.server.project.SubmitRuleOptions;
|
||||||
@@ -31,11 +30,9 @@ import com.google.gerrit.server.query.change.ChangeData;
|
|||||||
import com.google.gerrit.server.rules.RulesCache;
|
import com.google.gerrit.server.rules.RulesCache;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
|
|
||||||
public class TestSubmitType implements RestModifyView<RevisionResource, TestSubmitRuleInput> {
|
public class TestSubmitType implements RestModifyView<RevisionResource, TestSubmitRuleInput> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ChangeData.Factory changeDataFactory;
|
private final ChangeData.Factory changeDataFactory;
|
||||||
private final RulesCache rules;
|
private final RulesCache rules;
|
||||||
private final SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory;
|
private final SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory;
|
||||||
@@ -45,11 +42,9 @@ public class TestSubmitType implements RestModifyView<RevisionResource, TestSubm
|
|||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TestSubmitType(
|
TestSubmitType(
|
||||||
Provider<ReviewDb> db,
|
|
||||||
ChangeData.Factory changeDataFactory,
|
ChangeData.Factory changeDataFactory,
|
||||||
RulesCache rules,
|
RulesCache rules,
|
||||||
SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory) {
|
SubmitRuleEvaluator.Factory submitRuleEvaluatorFactory) {
|
||||||
this.db = db;
|
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
this.submitRuleEvaluatorFactory = submitRuleEvaluatorFactory;
|
this.submitRuleEvaluatorFactory = submitRuleEvaluatorFactory;
|
||||||
@@ -74,7 +69,7 @@ public class TestSubmitType implements RestModifyView<RevisionResource, TestSubm
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
SubmitRuleEvaluator evaluator = submitRuleEvaluatorFactory.create(opts);
|
SubmitRuleEvaluator evaluator = submitRuleEvaluatorFactory.create(opts);
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
SubmitTypeRecord rec = evaluator.getSubmitType(cd);
|
SubmitTypeRecord rec = evaluator.getSubmitType(cd);
|
||||||
|
|
||||||
if (rec.status != SubmitTypeRecord.Status.OK) {
|
if (rec.status != SubmitTypeRecord.Status.OK) {
|
||||||
|
|||||||
@@ -23,13 +23,11 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
|||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
|
||||||
import com.google.gerrit.server.ApprovalsUtil;
|
import com.google.gerrit.server.ApprovalsUtil;
|
||||||
import com.google.gerrit.server.change.ReviewerResource;
|
import com.google.gerrit.server.change.ReviewerResource;
|
||||||
import com.google.gerrit.server.change.VoteResource;
|
import com.google.gerrit.server.change.VoteResource;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -66,12 +64,10 @@ public class Votes implements ChildCollection<ReviewerResource, VoteResource> {
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class List implements RestReadView<ReviewerResource> {
|
public static class List implements RestReadView<ReviewerResource> {
|
||||||
private final Provider<ReviewDb> db;
|
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
List(Provider<ReviewDb> db, ApprovalsUtil approvalsUtil) {
|
List(ApprovalsUtil approvalsUtil) {
|
||||||
this.db = db;
|
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +81,6 @@ public class Votes implements ChildCollection<ReviewerResource, VoteResource> {
|
|||||||
Map<String, Short> votes = new TreeMap<>();
|
Map<String, Short> votes = new TreeMap<>();
|
||||||
Iterable<PatchSetApproval> byPatchSetUser =
|
Iterable<PatchSetApproval> byPatchSetUser =
|
||||||
approvalsUtil.byPatchSetUser(
|
approvalsUtil.byPatchSetUser(
|
||||||
db.get(),
|
|
||||||
rsrc.getChangeResource().getNotes(),
|
rsrc.getChangeResource().getNotes(),
|
||||||
rsrc.getChange().currentPatchSetId(),
|
rsrc.getChange().currentPatchSetId(),
|
||||||
rsrc.getReviewerUser().getAccountId(),
|
rsrc.getReviewerUser().getAccountId(),
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation {
|
|||||||
walkChangesByHashes(visibleCommits, Collections.emptySet(), or, b);
|
walkChangesByHashes(visibleCommits, Collections.emptySet(), or, b);
|
||||||
Set<String> nonVisibleHashes = walkChangesByHashes(nonVisibleCommits, visibleHashes, or, b);
|
Set<String> nonVisibleHashes = walkChangesByHashes(nonVisibleCommits, visibleHashes, or, b);
|
||||||
|
|
||||||
ChangeSet partialSet = byCommitsOnBranchNotMerged(or, db, b, visibleHashes, nonVisibleHashes);
|
ChangeSet partialSet = byCommitsOnBranchNotMerged(or, b, visibleHashes, nonVisibleHashes);
|
||||||
Iterables.addAll(visibleChanges, partialSet.changes());
|
Iterables.addAll(visibleChanges, partialSet.changes());
|
||||||
Iterables.addAll(nonVisibleChanges, partialSet.nonVisibleChanges());
|
Iterables.addAll(nonVisibleChanges, partialSet.nonVisibleChanges());
|
||||||
}
|
}
|
||||||
@@ -212,16 +212,12 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ChangeSet byCommitsOnBranchNotMerged(
|
private ChangeSet byCommitsOnBranchNotMerged(
|
||||||
OpenRepo or,
|
OpenRepo or, Branch.NameKey branch, Set<String> visibleHashes, Set<String> nonVisibleHashes)
|
||||||
ReviewDb db,
|
|
||||||
Branch.NameKey branch,
|
|
||||||
Set<String> visibleHashes,
|
|
||||||
Set<String> nonVisibleHashes)
|
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
List<ChangeData> potentiallyVisibleChanges =
|
List<ChangeData> potentiallyVisibleChanges =
|
||||||
byCommitsOnBranchNotMerged(or, db, branch, visibleHashes);
|
byCommitsOnBranchNotMerged(or, branch, visibleHashes);
|
||||||
List<ChangeData> invisibleChanges =
|
List<ChangeData> invisibleChanges =
|
||||||
new ArrayList<>(byCommitsOnBranchNotMerged(or, db, branch, nonVisibleHashes));
|
new ArrayList<>(byCommitsOnBranchNotMerged(or, branch, nonVisibleHashes));
|
||||||
List<ChangeData> visibleChanges = new ArrayList<>(potentiallyVisibleChanges.size());
|
List<ChangeData> visibleChanges = new ArrayList<>(potentiallyVisibleChanges.size());
|
||||||
for (ChangeData cd : potentiallyVisibleChanges) {
|
for (ChangeData cd : potentiallyVisibleChanges) {
|
||||||
if (changeIsVisibleToPredicate.match(cd)) {
|
if (changeIsVisibleToPredicate.match(cd)) {
|
||||||
@@ -234,8 +230,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableList<ChangeData> byCommitsOnBranchNotMerged(
|
private ImmutableList<ChangeData> byCommitsOnBranchNotMerged(
|
||||||
OpenRepo or, ReviewDb db, Branch.NameKey branch, Set<String> hashes)
|
OpenRepo or, Branch.NameKey branch, Set<String> hashes) throws OrmException, IOException {
|
||||||
throws OrmException, IOException {
|
|
||||||
if (hashes.isEmpty()) {
|
if (hashes.isEmpty()) {
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
@@ -245,7 +240,7 @@ public class LocalMergeSuperSetComputation implements MergeSuperSetComputation {
|
|||||||
}
|
}
|
||||||
ImmutableList<ChangeData> result =
|
ImmutableList<ChangeData> result =
|
||||||
ImmutableList.copyOf(
|
ImmutableList.copyOf(
|
||||||
queryProvider.get().byCommitsOnBranchNotMerged(or.repo, db, branch, hashes));
|
queryProvider.get().byCommitsOnBranchNotMerged(or.repo, branch, hashes));
|
||||||
queryCache.put(k, result);
|
queryCache.put(k, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -542,12 +542,10 @@ public class MergeOp implements AutoCloseable {
|
|||||||
private ChangeSet reloadChanges(ChangeSet changeSet) {
|
private ChangeSet reloadChanges(ChangeSet changeSet) {
|
||||||
List<ChangeData> visible = new ArrayList<>(changeSet.changes().size());
|
List<ChangeData> visible = new ArrayList<>(changeSet.changes().size());
|
||||||
List<ChangeData> nonVisible = new ArrayList<>(changeSet.nonVisibleChanges().size());
|
List<ChangeData> nonVisible = new ArrayList<>(changeSet.nonVisibleChanges().size());
|
||||||
changeSet
|
changeSet.changes().forEach(c -> visible.add(changeDataFactory.create(c.project(), c.getId())));
|
||||||
.changes()
|
|
||||||
.forEach(c -> visible.add(changeDataFactory.create(db, c.project(), c.getId())));
|
|
||||||
changeSet
|
changeSet
|
||||||
.nonVisibleChanges()
|
.nonVisibleChanges()
|
||||||
.forEach(c -> nonVisible.add(changeDataFactory.create(db, c.project(), c.getId())));
|
.forEach(c -> nonVisible.add(changeDataFactory.create(c.project(), c.getId())));
|
||||||
return new ChangeSet(visible, nonVisible);
|
return new ChangeSet(visible, nonVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,7 +347,7 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
|
|||||||
Map<PatchSetApproval.Key, PatchSetApproval> byKey = new HashMap<>();
|
Map<PatchSetApproval.Key, PatchSetApproval> byKey = new HashMap<>();
|
||||||
for (PatchSetApproval psa :
|
for (PatchSetApproval psa :
|
||||||
args.approvalsUtil.byPatchSet(
|
args.approvalsUtil.byPatchSet(
|
||||||
ctx.getDb(), ctx.getNotes(), psId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) {
|
ctx.getNotes(), psId, ctx.getRevWalk(), ctx.getRepoView().getConfig())) {
|
||||||
byKey.put(psa.getKey(), psa);
|
byKey.put(psa.getKey(), psa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ public class RefAdvertisementIT extends AbstractDaemonTest {
|
|||||||
+ subject
|
+ subject
|
||||||
+ "\n")
|
+ "\n")
|
||||||
.create();
|
.create();
|
||||||
indexer.index(db, c.getProject(), c.getId());
|
indexer.index(c.getProject(), c.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(getReceivePackRefs().additionalHaves()).containsExactly(obj(c4, 1));
|
assertThat(getReceivePackRefs().additionalHaves()).containsExactly(obj(c4, 1));
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class SubmitOnPushIT extends AbstractDaemonTest {
|
|||||||
testRepo.reset(c1);
|
testRepo.reset(c1);
|
||||||
assertPushOk(pushHead(testRepo, "refs/heads/master", false), "refs/heads/master");
|
assertPushOk(pushHead(testRepo, "refs/heads/master", false), "refs/heads/master");
|
||||||
|
|
||||||
cd = changeDataFactory.create(db, project, psId1.getParentKey());
|
cd = changeDataFactory.create(project, psId1.getParentKey());
|
||||||
Change c = cd.change();
|
Change c = cd.change();
|
||||||
assertThat(c.getStatus()).isEqualTo(Change.Status.MERGED);
|
assertThat(c.getStatus()).isEqualTo(Change.Status.MERGED);
|
||||||
assertThat(c.currentPatchSetId()).isEqualTo(psId1);
|
assertThat(c.currentPatchSetId()).isEqualTo(psId1);
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ public class ActionsIT extends AbstractDaemonTest {
|
|||||||
visitedCurrentRevisionActionsAssertions(origActions, revisionInfo.actions);
|
visitedCurrentRevisionActionsAssertions(origActions, revisionInfo.actions);
|
||||||
|
|
||||||
// ...via ChangeJson directly.
|
// ...via ChangeJson directly.
|
||||||
ChangeData cd = changeDataFactory.create(db, project, changeId);
|
ChangeData cd = changeDataFactory.create(project, changeId);
|
||||||
revisionJsonFactory.create(opts).getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
|
revisionJsonFactory.create(opts).getRevisionInfo(cd, cd.patchSet(new PatchSet.Id(changeId, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
+ "Groups: "
|
+ "Groups: "
|
||||||
+ rev
|
+ rev
|
||||||
+ "\n");
|
+ "\n");
|
||||||
indexer.index(db, c.getProject(), c.getId());
|
indexer.index(c.getProject(), c.getId());
|
||||||
ChangeNotes notes = changeNotesFactory.create(c.getProject(), c.getId());
|
ChangeNotes notes = changeNotesFactory.create(c.getProject(), c.getId());
|
||||||
|
|
||||||
FixInput fix = new FixInput();
|
FixInput fix = new FixInput();
|
||||||
@@ -817,7 +817,7 @@ public class ConsistencyCheckerIT extends AbstractDaemonTest {
|
|||||||
+ "Subject: "
|
+ "Subject: "
|
||||||
+ subject
|
+ subject
|
||||||
+ "\n");
|
+ "\n");
|
||||||
indexer.index(db, c.getProject(), c.getId());
|
indexer.index(c.getProject(), c.getId());
|
||||||
|
|
||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
// Pretend PS1,1 was pushed before the groups field was added.
|
// Pretend PS1,1 was pushed before the groups field was added.
|
||||||
clearGroups(psId1_1);
|
clearGroups(psId1_1);
|
||||||
indexer.index(changeDataFactory.create(db, project, psId1_1.getParentKey()));
|
indexer.index(changeDataFactory.create(project, psId1_1.getParentKey()));
|
||||||
|
|
||||||
// PS1,1 has no groups, so disappeared from related changes.
|
// PS1,1 has no groups, so disappeared from related changes.
|
||||||
assertRelated(psId2_1);
|
assertRelated(psId2_1);
|
||||||
|
|||||||
@@ -1759,7 +1759,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
|
allUsers.update(draftsRef.getName(), draftsRef.getObjectId());
|
||||||
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
|
assertThat(allUsers.getRepository().exactRef(draftsRef.getName())).isNotNull();
|
||||||
|
|
||||||
indexer.index(db, project, id);
|
indexer.index(project, id);
|
||||||
assertQuery("draftby:" + userId);
|
assertQuery("draftby:" + userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2261,7 +2261,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
|
|||||||
|
|
||||||
for (int i = 1; i <= 11; i++) {
|
for (int i = 1; i <= 11; i++) {
|
||||||
Iterable<ChangeData> cds =
|
Iterable<ChangeData> cds =
|
||||||
queryProvider.get().byCommitsOnBranchNotMerged(repo.getRepository(), db, dest, shas, i);
|
queryProvider.get().byCommitsOnBranchNotMerged(repo.getRepository(), dest, shas, i);
|
||||||
Iterable<Integer> ids = FluentIterable.from(cds).transform(in -> in.getId().get());
|
Iterable<Integer> ids = FluentIterable.from(cds).transform(in -> in.getId().get());
|
||||||
String name = "limit " + i;
|
String name = "limit " + i;
|
||||||
assertThat(ids).named(name).hasSize(n);
|
assertThat(ids).named(name).hasSize(n);
|
||||||
|
|||||||
Submodule plugins/reviewnotes updated: b98d892034...5d607a4193
Reference in New Issue
Block a user