Search in sources :

Example 11 with RevId

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);
}
Also used : ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) PatchSet(com.google.gerrit.reviewdb.client.PatchSet) RevId(com.google.gerrit.reviewdb.client.RevId)

Example 12 with RevId

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

Example 13 with RevId

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

Example 14 with RevId

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

Example 15 with RevId

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

Aggregations

RevId (com.google.gerrit.reviewdb.client.RevId)22 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)16 Change (com.google.gerrit.reviewdb.client.Change)13 Test (org.junit.Test)11 Comment (com.google.gerrit.reviewdb.client.Comment)4 LabelId (com.google.gerrit.reviewdb.client.LabelId)3 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)3 ChangeData (com.google.gerrit.server.query.change.ChangeData)3 Timestamp (java.sql.Timestamp)3 Note (org.eclipse.jgit.notes.Note)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 Account (com.google.gerrit.reviewdb.client.Account)2 CommentRange (com.google.gerrit.reviewdb.client.CommentRange)2 Project (com.google.gerrit.reviewdb.client.Project)2 OrmException (com.google.gwtorm.server.OrmException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2