Search Change-Id strings using ChangeIndex

Move the legacy Change.Id value to _id field and implement change_id
field as the Change-Id string, taking advantage of the existing PREFIX
support added for commit.

Change-Id: I94b924f14474fb2d364819b9950ba3e85a2b2db9
This commit is contained in:
Shawn Pearce
2013-06-25 20:06:00 -06:00
parent 79322b058e
commit 2a94e48457
4 changed files with 22 additions and 10 deletions

View File

@@ -44,11 +44,11 @@ import java.util.Set;
*/
public class ChangeField {
/** Increment whenever making schema changes. */
public static final int SCHEMA_VERSION = 6;
public static final int SCHEMA_VERSION = 7;
/** Legacy change ID. */
public static final FieldDef<ChangeData, Integer> CHANGE_ID =
new FieldDef.Single<ChangeData, Integer>(ChangeQueryBuilder.FIELD_CHANGE,
public static final FieldDef<ChangeData, Integer> LEGACY_ID =
new FieldDef.Single<ChangeData, Integer>("_id",
FieldType.INTEGER, true) {
@Override
public Integer get(ChangeData input, FillArgs args) {
@@ -56,6 +56,17 @@ public class ChangeField {
}
};
/** Newer style Change-Id key. */
public static final FieldDef<ChangeData, String> ID =
new FieldDef.Single<ChangeData, String>("change_id",
FieldType.PREFIX, true) {
@Override
public String get(ChangeData input, FillArgs args)
throws OrmException {
return input.change(args.db).getKey().get();
}
};
/** Change status string, in the same format as {@code status:}. */
public static final FieldDef<ChangeData, String> STATUS =
new FieldDef.Single<ChangeData, String>(ChangeQueryBuilder.FIELD_STATUS,