use of com.google.gerrit.reviewdb.client.PatchLineComment in project gerrit by GerritCodeReview.
the class ChangeBundle method getLatestTimestamp.
private Timestamp getLatestTimestamp() {
Ordering<Timestamp> o = Ordering.natural().nullsFirst();
Timestamp ts = null;
for (ChangeMessage cm : filterChangeMessages()) {
ts = o.max(ts, cm.getWrittenOn());
}
for (PatchSet ps : getPatchSets()) {
ts = o.max(ts, ps.getCreatedOn());
}
for (PatchSetApproval psa : filterPatchSetApprovals().values()) {
ts = o.max(ts, psa.getGranted());
}
for (PatchLineComment plc : filterPatchLineComments().values()) {
// Ignore draft comments, as they do not show up in the change meta graph.
if (plc.getStatus() != PatchLineComment.Status.DRAFT) {
ts = o.max(ts, plc.getWrittenOn());
}
}
return firstNonNull(ts, change.getLastUpdatedOn());
}
use of com.google.gerrit.reviewdb.client.PatchLineComment in project gerrit by GerritCodeReview.
the class ChangeBundle method diffPatchLineComments.
private static void diffPatchLineComments(List<String> diffs, ChangeBundle bundleA, ChangeBundle bundleB) {
Map<PatchLineComment.Key, PatchLineComment> as = bundleA.filterPatchLineComments();
Map<PatchLineComment.Key, PatchLineComment> bs = bundleB.filterPatchLineComments();
for (PatchLineComment.Key k : diffKeySets(diffs, as, bs)) {
PatchLineComment a = as.get(k);
PatchLineComment b = bs.get(k);
String desc = describe(k);
diffColumns(diffs, PatchLineComment.class, desc, bundleA, a, bundleB, b);
}
}
use of com.google.gerrit.reviewdb.client.PatchLineComment in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchLineCommentsMixedSourcesAllowsSlop.
@Test
public void diffPatchLineCommentsMixedSourcesAllowsSlop() throws Exception {
subWindowResolution();
Change c = TestChanges.newChange(project, accountId);
PatchLineComment c1 = new PatchLineComment(new PatchLineComment.Key(new Patch.Key(c.currentPatchSetId(), "filename"), "uuid"), 5, accountId, null, roundToSecond(TimeUtil.nowTs()));
PatchLineComment c2 = clone(c1);
c2.setWrittenOn(TimeUtil.nowTs());
// Both are ReviewDb, exact timestamp match is required.
ChangeBundle b1 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c1), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c2), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "writtenOn differs for PatchLineComment.Key " + c.getId() + ",1,filename,uuid:" + " {2009-09-30 17:00:02.0} != {2009-09-30 17:00:03.0}");
// One NoteDb, slop is allowed.
b1 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c1), reviewers(), NOTE_DB);
b2 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c2), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
// But not too much slop.
superWindowResolution();
PatchLineComment c3 = clone(c1);
c3.setWrittenOn(TimeUtil.nowTs());
b1 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c1), reviewers(), NOTE_DB);
ChangeBundle b3 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c3), reviewers(), REVIEW_DB);
String msg = "writtenOn differs for PatchLineComment.Key " + c.getId() + ",1,filename,uuid 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.PatchLineComment in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffPatchLineCommentsIgnoresCommentsOnInvalidPatchSet.
@Test
public void diffPatchLineCommentsIgnoresCommentsOnInvalidPatchSet() throws Exception {
Change c = TestChanges.newChange(project, accountId);
PatchLineComment c1 = new PatchLineComment(new PatchLineComment.Key(new Patch.Key(c.currentPatchSetId(), "filename1"), "uuid1"), 5, accountId, null, TimeUtil.nowTs());
PatchLineComment c2 = new PatchLineComment(new PatchLineComment.Key(new Patch.Key(new PatchSet.Id(c.getId(), 0), "filename2"), "uuid2"), 5, accountId, null, TimeUtil.nowTs());
ChangeBundle b1 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c1, c2), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c, messages(), latest(c), approvals(), comments(c1), reviewers(), REVIEW_DB);
assertNoDiffs(b1, b2);
}
Aggregations