ChangeRebuilderImpl: Skip patch sets greater than current
AOSP has some changes[1] dating from before we used transactions properly, where there is a PatchSet entity with an ID higher than the currentPatchSetId in the Change entity. In NoteDb we don't record the current patch set ID explicitly, we just use the greatest (non-deleted) ID found in the meta graph, so we can't represent this discrepancy. Just don't convert these newer patch sets or their associated entities, and teach ChangeBundle to ignore this diff. This means we might end up discarding some comments of the form "What's the deal with this extra patch set?", which seems acceptable. [1] https://android-review.googlesource.com/31041 Change-Id: I30e55f6455fe8db3dac3d2502e5e5eafc5bc2438
This commit is contained in:
@@ -705,6 +705,48 @@ public class ChangeBundleTest {
|
||||
assertNoDiffs(b2, b1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffPatchSetsIgnoresGreaterThanCurrentFromReviewDb()
|
||||
throws Exception {
|
||||
Change c = TestChanges.newChange(project, accountId);
|
||||
|
||||
PatchSet ps1 = new PatchSet(new PatchSet.Id(c.getId(), 1));
|
||||
ps1.setRevision(new RevId("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
|
||||
ps1.setUploader(accountId);
|
||||
ps1.setCreatedOn(TimeUtil.nowTs());
|
||||
PatchSet ps2 = new PatchSet(new PatchSet.Id(c.getId(), 2));
|
||||
ps2.setRevision(new RevId("badc0feebadc0feebadc0feebadc0feebadc0fee"));
|
||||
ps2.setUploader(accountId);
|
||||
ps2.setCreatedOn(TimeUtil.nowTs());
|
||||
assertThat(ps2.getId().get()).isGreaterThan(c.currentPatchSetId().get());
|
||||
|
||||
// Both ReviewDb, exact match is required.
|
||||
ChangeBundle b1 = new ChangeBundle(c, messages(), patchSets(ps1),
|
||||
approvals(), comments(), REVIEW_DB);
|
||||
ChangeBundle b2 = new ChangeBundle(c, messages(), patchSets(ps1, ps2),
|
||||
approvals(), comments(), REVIEW_DB);
|
||||
assertDiffs(b1, b2,
|
||||
"PatchSet.Id sets differ:"
|
||||
+ " [] only in A; [" + c.getId() + ",2] only in B");
|
||||
|
||||
// Both NoteDb, exact match is required.
|
||||
b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(),
|
||||
comments(), NOTE_DB);
|
||||
b2 = new ChangeBundle(c, messages(), patchSets(ps1, ps2), approvals(),
|
||||
comments(), NOTE_DB);
|
||||
assertDiffs(b1, b2,
|
||||
"PatchSet.Id sets differ:"
|
||||
+ " [] only in A; [" + c.getId() + ",2] only in B");
|
||||
|
||||
// PS2 is in ReviewDb but not NoteDb, ok.
|
||||
b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(),
|
||||
comments(), NOTE_DB);
|
||||
b2 = new ChangeBundle(c, messages(), patchSets(ps1, ps2), approvals(),
|
||||
comments(), REVIEW_DB);
|
||||
assertNoDiffs(b1, b2);
|
||||
assertNoDiffs(b2, b1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diffPatchSetApprovalKeySets() throws Exception {
|
||||
Change c = TestChanges.newChange(project, accountId);
|
||||
|
Reference in New Issue
Block a user