use of com.google.gerrit.reviewdb.client.RevId in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parsePatchSet.
private void parsePatchSet(PatchSet.Id psId, ObjectId rev, Account.Id accountId, Timestamp ts) throws ConfigInvalidException {
if (accountId == null) {
throw parseException("patch set %s requires an identified user as uploader", psId.get());
}
PatchSet ps = patchSets.get(psId);
if (ps == null) {
ps = new PatchSet(psId);
patchSets.put(psId, ps);
} else if (!ps.getRevision().equals(PARTIAL_PATCH_SET)) {
if (deletedPatchSets.contains(psId)) {
// no relevance
return;
}
throw new ConfigInvalidException(String.format("Multiple revisions parsed for patch set %s: %s and %s", psId.get(), patchSets.get(psId).getRevision(), rev.name()));
}
ps.setRevision(new RevId(rev.name()));
ps.setUploader(accountId);
ps.setCreatedOn(ts);
}
use of com.google.gerrit.reviewdb.client.RevId in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchSetsMixedSourcesAllowsSlop.
@Test
public void diffPatchSetsMixedSourcesAllowsSlop() throws Exception {
subWindowResolution();
Change c = TestChanges.newChange(project, accountId);
PatchSet ps1 = new PatchSet(c.currentPatchSetId());
ps1.setRevision(new RevId("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
ps1.setUploader(accountId);
ps1.setCreatedOn(roundToSecond(TimeUtil.nowTs()));
PatchSet ps2 = clone(ps1);
ps2.setCreatedOn(TimeUtil.nowTs());
// Both are ReviewDb, exact timestamp match is required.
ChangeBundle b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), patchSets(ps2), approvals(), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "createdOn differs for PatchSet.Id " + c.getId() + ",1:" + " {2009-09-30 17:00:02.0} != {2009-09-30 17:00:03.0}");
// One NoteDb, slop is allowed.
b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(), comments(), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(), patchSets(ps2), approvals(), comments(), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
// But not too much slop.
superWindowResolution();
PatchSet ps3 = clone(ps1);
ps3.setCreatedOn(TimeUtil.nowTs());
b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(), comments(), reviewers(), NOTE_DB);
ChangeBundle b3 = new ChangeBundle(c, messages(), patchSets(ps3), approvals(), comments(), reviewers(), REVIEW_DB);
String msg = "createdOn differs for PatchSet.Id " + c.getId() + ",1 in NoteDb vs. ReviewDb:" + " {2009-09-30 17:00:02.0} != {2009-09-30 17:00:10.0}";
assertDiffs(b1, b3, msg);
assertDiffs(b3, b1, msg);
}
use of com.google.gerrit.reviewdb.client.RevId in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchSetIdSets.
@Test
public void diffPatchSetIdSets() throws Exception {
Change c = TestChanges.newChange(project, accountId);
TestChanges.incrementPatchSet(c);
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());
ChangeBundle b1 = new ChangeBundle(c, messages(), patchSets(ps2), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), patchSets(ps1, ps2), approvals(), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "PatchSet.Id sets differ: [] only in A; [" + c.getId() + ",1] only in B");
}
use of com.google.gerrit.reviewdb.client.RevId in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchSetsGreaterThanCurrent.
@Test
public void diffPatchSetsGreaterThanCurrent() 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());
ChangeMessage cm1 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid1"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
ChangeMessage cm2 = new ChangeMessage(new ChangeMessage.Key(c.getId(), "uuid2"), accountId, TimeUtil.nowTs(), c.currentPatchSetId());
PatchSetApproval a1 = new PatchSetApproval(new PatchSetApproval.Key(ps1.getId(), accountId, new LabelId("Code-Review")), (short) 1, TimeUtil.nowTs());
PatchSetApproval a2 = new PatchSetApproval(new PatchSetApproval.Key(ps2.getId(), accountId, new LabelId("Code-Review")), (short) 1, TimeUtil.nowTs());
// Both ReviewDb.
ChangeBundle b1 = new ChangeBundle(c, messages(cm1), patchSets(ps1), approvals(a1), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(cm1, cm2), patchSets(ps1, ps2), approvals(a1, a2), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "ChangeMessage.Key sets differ: [] only in A; [" + cm2.getKey() + "] only in B", "PatchSet.Id sets differ: [] only in A; [" + ps2.getId() + "] only in B", "PatchSetApproval.Key sets differ: [] only in A; [" + a2.getKey() + "] only in B");
// One NoteDb.
b1 = new ChangeBundle(c, messages(cm1), patchSets(ps1), approvals(a1), comments(), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(cm1, cm2), patchSets(ps1, ps2), approvals(a1, a2), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "ChangeMessages differ for Change.Id " + c.getId() + "\nOnly in B:\n " + cm2, "PatchSet.Id sets differ: [] only in A; [" + ps2.getId() + "] only in B", "PatchSetApproval.Key sets differ: [] only in A; [" + a2.getKey() + "] only in B");
// Both NoteDb.
b1 = new ChangeBundle(c, messages(cm1), patchSets(ps1), approvals(a1), comments(), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(cm1, cm2), patchSets(ps1, ps2), approvals(a1, a2), comments(), reviewers(), NOTE_DB);
assertDiffs(b1, b2, "ChangeMessages differ for Change.Id " + c.getId() + "\nOnly in B:\n " + cm2, "PatchSet.Id sets differ: [] only in A; [" + ps2.getId() + "] only in B", "PatchSetApproval.Key sets differ: [] only in A; [" + a2.getKey() + "] only in B");
}
use of com.google.gerrit.reviewdb.client.RevId in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchSets.
@Test
public void diffPatchSets() throws Exception {
Change c = TestChanges.newChange(project, accountId);
PatchSet ps1 = new PatchSet(c.currentPatchSetId());
ps1.setRevision(new RevId("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
ps1.setUploader(accountId);
ps1.setCreatedOn(TimeUtil.nowTs());
PatchSet ps2 = clone(ps1);
ChangeBundle b1 = new ChangeBundle(c, messages(), patchSets(ps1), approvals(), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), patchSets(ps2), approvals(), comments(), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
ps2.setRevision(new RevId("badc0feebadc0feebadc0feebadc0feebadc0fee"));
assertDiffs(b1, b2, "revision differs for PatchSet.Id " + c.getId() + ",1:" + " {RevId{deadbeefdeadbeefdeadbeefdeadbeefdeadbeef}}" + " != {RevId{badc0feebadc0feebadc0feebadc0feebadc0fee}}");
}
Aggregations