Search in sources :

Example 6 with PatchLineComment

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());
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) ChangeMessage(com.google.gerrit.reviewdb.client.ChangeMessage) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Timestamp(java.sql.Timestamp) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval)

Example 7 with PatchLineComment

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);
    }
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment)

Example 8 with PatchLineComment

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);
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Example 9 with PatchLineComment

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);
}
Also used : PatchLineComment(com.google.gerrit.reviewdb.client.PatchLineComment) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) Change(com.google.gerrit.reviewdb.client.Change) Test(org.junit.Test)

Aggregations

PatchLineComment (com.google.gerrit.reviewdb.client.PatchLineComment)9 Change (com.google.gerrit.reviewdb.client.Change)6 Test (org.junit.Test)6 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)4 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)2 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)2 ChangeMessage (com.google.gerrit.reviewdb.client.ChangeMessage)2 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)2 DraftInput (com.google.gerrit.extensions.api.changes.DraftInput)1 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)1 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)1 Patch (com.google.gerrit.reviewdb.client.Patch)1 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)1 BatchUpdateReviewDb (com.google.gerrit.server.update.BatchUpdateReviewDb)1 OrmException (com.google.gwtorm.server.OrmException)1 Timestamp (java.sql.Timestamp)1 Header (org.apache.http.Header)1 BasicHeader (org.apache.http.message.BasicHeader)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1