Remove special-casing of index schemas prior to PROJECT
Change-Id: I718af6f9f430c6606fe279a73021ee9f371a5a84
This commit is contained in:
@@ -401,23 +401,14 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
}
|
||||
|
||||
private Set<String> fields(QueryOptions opts) {
|
||||
// Ensure we request enough fields to construct a ChangeData.
|
||||
// Ensure we request enough fields to construct a ChangeData. We need both
|
||||
// change ID and project, which can either come via the Change field or
|
||||
// separate fields.
|
||||
Set<String> fs = opts.fields();
|
||||
if (fs.contains(CHANGE.getName())) {
|
||||
// A Change is always sufficient.
|
||||
return fs;
|
||||
}
|
||||
|
||||
if (!schema.hasField(PROJECT)) {
|
||||
// Schema is not new enough to have project field. Ensure we have ID
|
||||
// field, and call createOnlyWhenNoteDbDisabled from toChangeData below.
|
||||
if (fs.contains(LEGACY_ID.getName())) {
|
||||
return fs;
|
||||
}
|
||||
return Sets.union(fs, ImmutableSet.of(LEGACY_ID.getName()));
|
||||
}
|
||||
|
||||
// New enough schema to have project field, so ensure that is requested.
|
||||
if (fs.contains(PROJECT.getName()) && fs.contains(LEGACY_ID.getName())) {
|
||||
return fs;
|
||||
}
|
||||
|
||||
@@ -143,6 +143,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
private Change loadChangeFromDb(ReviewDb db, Project.NameKey project,
|
||||
Change.Id changeId) throws OrmException {
|
||||
Change change = ReviewDbUtil.unwrapDb(db).changes().get(changeId);
|
||||
checkArgument(project != null, "project is required");
|
||||
checkNotNull(change,
|
||||
"change %s not found in ReviewDb", changeId);
|
||||
checkArgument(change.getProject().equals(project),
|
||||
@@ -182,17 +183,6 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
||||
return new ChangeNotes(args, change, false, null).load();
|
||||
}
|
||||
|
||||
// TODO(dborowitz): Remove when deleting index schemas <27.
|
||||
public ChangeNotes createFromIdOnlyWhenNoteDbDisabled(
|
||||
ReviewDb db, Change.Id changeId) throws OrmException {
|
||||
checkState(!args.migration.readChanges(), "do not call"
|
||||
+ " createFromIdOnlyWhenNoteDbDisabled when NoteDb is enabled");
|
||||
Change change = ReviewDbUtil.unwrapDb(db).changes().get(changeId);
|
||||
checkNotNull(change,
|
||||
"change %s not found in ReviewDb", changeId);
|
||||
return new ChangeNotes(args, change).load();
|
||||
}
|
||||
|
||||
public ChangeNotes createWithAutoRebuildingDisabled(Change change,
|
||||
RefCache refs) throws OrmException {
|
||||
return new ChangeNotes(args, change, false, refs).load();
|
||||
|
||||
@@ -766,11 +766,7 @@ public class ChangeData {
|
||||
}
|
||||
|
||||
public Change reloadChange() throws OrmException {
|
||||
if (project == null) {
|
||||
notes = notesFactory.createFromIdOnlyWhenNoteDbDisabled(db, legacyId);
|
||||
} else {
|
||||
notes = notesFactory.create(db, project, legacyId);
|
||||
}
|
||||
notes = notesFactory.create(db, project, legacyId);
|
||||
change = notes.getChange();
|
||||
if (change == null) {
|
||||
throw new OrmException("Unable to load change " + legacyId);
|
||||
|
||||
Reference in New Issue
Block a user