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) {
|
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();
|
Set<String> fs = opts.fields();
|
||||||
if (fs.contains(CHANGE.getName())) {
|
if (fs.contains(CHANGE.getName())) {
|
||||||
// A Change is always sufficient.
|
// A Change is always sufficient.
|
||||||
return fs;
|
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())) {
|
if (fs.contains(PROJECT.getName()) && fs.contains(LEGACY_ID.getName())) {
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
private Change loadChangeFromDb(ReviewDb db, Project.NameKey project,
|
private Change loadChangeFromDb(ReviewDb db, Project.NameKey project,
|
||||||
Change.Id changeId) throws OrmException {
|
Change.Id changeId) throws OrmException {
|
||||||
Change change = ReviewDbUtil.unwrapDb(db).changes().get(changeId);
|
Change change = ReviewDbUtil.unwrapDb(db).changes().get(changeId);
|
||||||
|
checkArgument(project != null, "project is required");
|
||||||
checkNotNull(change,
|
checkNotNull(change,
|
||||||
"change %s not found in ReviewDb", changeId);
|
"change %s not found in ReviewDb", changeId);
|
||||||
checkArgument(change.getProject().equals(project),
|
checkArgument(change.getProject().equals(project),
|
||||||
@@ -182,17 +183,6 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
return new ChangeNotes(args, change, false, null).load();
|
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,
|
public ChangeNotes createWithAutoRebuildingDisabled(Change change,
|
||||||
RefCache refs) throws OrmException {
|
RefCache refs) throws OrmException {
|
||||||
return new ChangeNotes(args, change, false, refs).load();
|
return new ChangeNotes(args, change, false, refs).load();
|
||||||
|
|||||||
@@ -766,11 +766,7 @@ public class ChangeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Change reloadChange() throws OrmException {
|
public Change reloadChange() throws OrmException {
|
||||||
if (project == null) {
|
notes = notesFactory.create(db, project, legacyId);
|
||||||
notes = notesFactory.createFromIdOnlyWhenNoteDbDisabled(db, legacyId);
|
|
||||||
} else {
|
|
||||||
notes = notesFactory.create(db, project, legacyId);
|
|
||||||
}
|
|
||||||
change = notes.getChange();
|
change = notes.getChange();
|
||||||
if (change == null) {
|
if (change == null) {
|
||||||
throw new OrmException("Unable to load change " + legacyId);
|
throw new OrmException("Unable to load change " + legacyId);
|
||||||
|
|||||||
Reference in New Issue
Block a user