ChangeBundle: Ignore originalSubject between ReviewDb and NoteDb
The migration path in Change#setCurrentPatchSet means that the original subject field in ReviewDb may be null, or may be the actual original subject of PS1, or may be the subject of any intervening patch set, if that patch set was the first one pushed after adding the column to ReviewDb. This means we can't reliably compare these after converting to NoteDb, at least without changing the implementation of ChangeBundle substantially in order to give it access to the repository. Satisfy ourselves with explicitly checking the subject and originalSubject in ChangeRebuilderIT to ensure it's populated properly in the common case. Change-Id: I2160bf6f38b5ea97e0c3ee512a0450854e1af265
This commit is contained in:
		| @@ -182,14 +182,14 @@ public class ChangeBundleTest { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void diffChangesIgnoresNullOriginalSubjectInReviewDb() | ||||
|   public void diffChangesIgnoresOriginalSubjectInReviewDb() | ||||
|       throws Exception { | ||||
|     Change c1 = TestChanges.newChange( | ||||
|         new Project.NameKey("project"), new Account.Id(100)); | ||||
|     c1.setCurrentPatchSet(c1.currentPatchSetId(), "Subject", null); | ||||
|     c1.setCurrentPatchSet(c1.currentPatchSetId(), "Subject", "Original A"); | ||||
|     Change c2 = clone(c1); | ||||
|     c2.setCurrentPatchSet( | ||||
|         c2.currentPatchSetId(), c1.getSubject(), "Original subject"); | ||||
|         c2.currentPatchSetId(), c1.getSubject(), "Original B"); | ||||
|  | ||||
|     // Both ReviewDb, exact match required. | ||||
|     ChangeBundle b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), | ||||
| @@ -198,7 +198,7 @@ public class ChangeBundleTest { | ||||
|         comments(), REVIEW_DB); | ||||
|     assertDiffs(b1, b2, | ||||
|         "originalSubject differs for Change.Id " + c1.getId() + ":" | ||||
|             + " {null} != {Original subject}"); | ||||
|             + " {Original A} != {Original B}"); | ||||
|  | ||||
|     // Both NoteDb, exact match required. | ||||
|     b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(), | ||||
| @@ -207,23 +207,15 @@ public class ChangeBundleTest { | ||||
|         NOTE_DB); | ||||
|     assertDiffs(b1, b2, | ||||
|         "originalSubject differs for Change.Id " + c1.getId() + ":" | ||||
|             + " {null} != {Original subject}"); | ||||
|             + " {Original A} != {Original B}"); | ||||
|  | ||||
|     // Original subject ignored if ReviewDb has null value. | ||||
|     // One ReviewDb, one NoteDb, original subject is ignored. | ||||
|     b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(), | ||||
|         REVIEW_DB); | ||||
|     b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(), comments(), | ||||
|         NOTE_DB); | ||||
|     assertNoDiffs(b1, b2); | ||||
|  | ||||
|     // Exact match still required if NoteDb has null value (not realistic). | ||||
|     b1 = new ChangeBundle(c1, messages(), patchSets(), approvals(), comments(), | ||||
|         NOTE_DB); | ||||
|     b2 = new ChangeBundle(c2, messages(), patchSets(), approvals(), comments(), | ||||
|         REVIEW_DB); | ||||
|     assertDiffs(b1, b2, | ||||
|         "originalSubject differs for Change.Id " + c1.getId() + ":" | ||||
|             + " {null} != {Original subject}"); | ||||
|     assertNoDiffs(b2, b1); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dave Borowitz
					Dave Borowitz