use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeBundle method diffPatchSetApprovals.
private static void diffPatchSetApprovals(List<String> diffs, ChangeBundle bundleA, ChangeBundle bundleB) {
Map<PatchSetApproval.Key, PatchSetApproval> as = bundleA.filterPatchSetApprovals();
Map<PatchSetApproval.Key, PatchSetApproval> bs = bundleB.filterPatchSetApprovals();
for (PatchSetApproval.Key k : diffKeySets(diffs, as, bs)) {
PatchSetApproval a = as.get(k);
PatchSetApproval b = bs.get(k);
String desc = describe(k);
// ReviewDb allows timestamps before patch set was created, but NoteDb
// truncates this to the patch set creation timestamp.
//
// ChangeRebuilder ensures all post-submit approvals happen after the
// actual submit, so the timestamps may not line up. This shouldn't really
// happen, because postSubmit shouldn't be set in ReviewDb until after the
// change is submitted in ReviewDb, but you never know.
//
// Due to a quirk of PostReview, post-submit 0 votes might not have the
// postSubmit bit set in ReviewDb. As these are only used for tombstone
// purposes, ignore the postSubmit bit in NoteDb in this case.
Timestamp ta = a.getGranted();
Timestamp tb = b.getGranted();
PatchSet psa = checkNotNull(bundleA.patchSets.get(a.getPatchSetId()));
PatchSet psb = checkNotNull(bundleB.patchSets.get(b.getPatchSetId()));
boolean excludeGranted = false;
boolean excludePostSubmit = false;
List<String> exclude = new ArrayList<>(1);
if (bundleA.source == REVIEW_DB && bundleB.source == NOTE_DB) {
excludeGranted = (ta.before(psa.getCreatedOn()) && tb.equals(psb.getCreatedOn())) || ta.compareTo(tb) < 0;
excludePostSubmit = a.getValue() == 0 && b.isPostSubmit();
} else if (bundleA.source == NOTE_DB && bundleB.source == REVIEW_DB) {
excludeGranted = tb.before(psb.getCreatedOn()) && ta.equals(psa.getCreatedOn()) || tb.compareTo(ta) < 0;
excludePostSubmit = b.getValue() == 0 && a.isPostSubmit();
}
// Legacy submit approvals may or may not have tags associated with them,
// depending on whether ChangeRebuilder happened to group them with the
// status change.
boolean excludeTag = bundleA.source != bundleB.source && a.isLegacySubmit() && b.isLegacySubmit();
if (excludeGranted) {
exclude.add("granted");
}
if (excludePostSubmit) {
exclude.add("postSubmit");
}
if (excludeTag) {
exclude.add("tag");
}
diffColumnsExcluding(diffs, PatchSetApproval.class, desc, bundleA, a, bundleB, b, exclude);
}
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeNotes method getPatchSets.
public ImmutableSortedMap<PatchSet.Id, PatchSet> getPatchSets() {
if (patchSets == null) {
ImmutableSortedMap.Builder<PatchSet.Id, PatchSet> b = ImmutableSortedMap.orderedBy(comparing(PatchSet.Id::get));
for (Map.Entry<PatchSet.Id, PatchSet> e : state.patchSets()) {
b.put(e.getKey(), new PatchSet(e.getValue()));
}
patchSets = b.build();
}
return patchSets;
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class PRED_uploader_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
PatchSet patchSet = StoredValues.getPatchSet(engine);
if (patchSet == null) {
log.error("Failed to load current patch set of change " + StoredValues.getChange(engine).getChangeId());
return engine.fail();
}
Account.Id uploaderId = patchSet.getUploader();
if (!a1.unify(new StructureTerm(user, new IntegerTerm(uploaderId.get())), engine.trail)) {
return engine.fail();
}
return cont;
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeBundleTest method latest.
private static List<PatchSet> latest(Change c) {
PatchSet ps = new PatchSet(c.currentPatchSetId());
ps.setCreatedOn(c.getLastUpdatedOn());
return ImmutableList.of(ps);
}
use of com.google.gerrit.reviewdb.client.PatchSet in project gerrit by GerritCodeReview.
the class ChangeBundleTest method diffChangesTakesMaxEntityTimestampFromReviewDb.
@Test
public void diffChangesTakesMaxEntityTimestampFromReviewDb() throws Exception {
Change c1 = TestChanges.newChange(new Project.NameKey("project"), new Account.Id(100));
PatchSet ps = new PatchSet(c1.currentPatchSetId());
ps.setRevision(new RevId("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"));
ps.setUploader(accountId);
ps.setCreatedOn(TimeUtil.nowTs());
PatchSetApproval a = new PatchSetApproval(new PatchSetApproval.Key(c1.currentPatchSetId(), accountId, new LabelId("Code-Review")), (short) 1, TimeUtil.nowTs());
Change c2 = clone(c1);
c2.setLastUpdatedOn(a.getGranted());
// Both ReviewDb, exact match required.
ChangeBundle b1 = new ChangeBundle(c1, messages(), patchSets(ps), approvals(a), comments(), reviewers(), REVIEW_DB);
ChangeBundle b2 = new ChangeBundle(c2, messages(), patchSets(ps), approvals(a), comments(), reviewers(), REVIEW_DB);
assertDiffs(b1, b2, "effective last updated time differs for Change.Id " + c1.getId() + ":" + " {2009-09-30 17:00:00.0} != {2009-09-30 17:00:12.0}");
// NoteDb allows latest timestamp from all entities in bundle.
b2 = new ChangeBundle(c2, messages(), patchSets(ps), approvals(a), comments(), reviewers(), NOTE_DB);
assertNoDiffs(b1, b2);
}
Aggregations