Rework SUBM label in LabelId
Use a static method instead of a public LabelId field. LabelId is mutable, so naming it like a constant is misleading at best. At worst, a caller could call SUBMIT.set(newValue) and change the value seen by all callers in the process. (Fortunately no callers were doing this as far as I could tell.) While we're in there, rename methods to refer to this as a "legacy" submit label, as we want to eventually get rid of it in NoteDb. Change-Id: Id7fbddfaac1d625839c66c73231d4e4ba2550c50
This commit is contained in:
@@ -321,7 +321,7 @@ public class ApprovalsUtil {
|
||||
}
|
||||
PatchSetApproval submitter = null;
|
||||
for (PatchSetApproval a : approvals) {
|
||||
if (a.getPatchSetId().equals(c) && a.getValue() > 0 && a.isSubmit()) {
|
||||
if (a.getPatchSetId().equals(c) && a.getValue() > 0 && a.isLegacySubmit()) {
|
||||
if (submitter == null
|
||||
|| a.getGranted().compareTo(submitter.getGranted()) > 0) {
|
||||
submitter = a;
|
||||
|
||||
@@ -611,7 +611,7 @@ public class PostReview implements RestModifyView<RevisionResource, ReviewInput>
|
||||
|
||||
for (PatchSetApproval a : approvalsUtil.byPatchSetUser(
|
||||
ctx.getDb(), ctx.getControl(), psId, user.getAccountId())) {
|
||||
if (a.isSubmit()) {
|
||||
if (a.isLegacySubmit()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ public class LabelNormalizer {
|
||||
checkArgument(changeId.equals(ctl.getId()),
|
||||
"Approval %s does not match change %s",
|
||||
psa.getKey(), ctl.getChange().getKey());
|
||||
if (psa.isSubmit()) {
|
||||
if (psa.isLegacySubmit()) {
|
||||
unchanged.add(psa);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class MergeUtil {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (a.isSubmit()) {
|
||||
if (a.isLegacySubmit()) {
|
||||
// Submit is treated specially, below (becomes committer)
|
||||
//
|
||||
if (submitAudit == null
|
||||
|
||||
@@ -2565,7 +2565,7 @@ public class ReceiveCommits {
|
||||
new PatchSetApproval.Key(
|
||||
change.currentPatchSetId(),
|
||||
ctx.getUser().getAccountId(),
|
||||
LabelId.SUBMIT),
|
||||
LabelId.legacySubmit()),
|
||||
(short) 1, ctx.getWhen());
|
||||
update.putApproval(submitter.getLabel(), submitter.getValue());
|
||||
ctx.getDb().patchSetApprovals().upsert(
|
||||
|
||||
@@ -301,7 +301,7 @@ public class ReplaceOp extends BatchUpdate.Op {
|
||||
for (PatchSetApproval a : approvalsUtil.byPatchSetUser(ctx.getDb(),
|
||||
ctx.getControl(), priorPatchSetId,
|
||||
ctx.getUser().getAccountId())) {
|
||||
if (a.isSubmit()) {
|
||||
if (a.isLegacySubmit()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
|
||||
new PatchSetApproval.Key(
|
||||
psId,
|
||||
ctx.getUser().getAccountId(),
|
||||
LabelId.SUBMIT),
|
||||
LabelId.legacySubmit()),
|
||||
(short) 1, ctx.getWhen());
|
||||
byKey.put(submitter.getKey(), submitter);
|
||||
submitter.setValue((short) 1);
|
||||
@@ -373,7 +373,7 @@ abstract class SubmitStrategyOp extends BatchUpdate.Op {
|
||||
// TODO(dborowitz): Don't use a label in notedb; just check when status
|
||||
// change happened.
|
||||
for (PatchSetApproval psa : normalized.unchanged()) {
|
||||
if (includeUnchanged || psa.isSubmit()) {
|
||||
if (includeUnchanged || psa.isLegacySubmit()) {
|
||||
logDebug("Adding submit label " + psa);
|
||||
update.putApprovalFor(
|
||||
psa.getAccountId(), psa.getLabel(), psa.getValue());
|
||||
|
||||
@@ -359,7 +359,7 @@ public class ChangeField {
|
||||
Set<String> allApprovals = Sets.newHashSet();
|
||||
Set<String> distinctApprovals = Sets.newHashSet();
|
||||
for (PatchSetApproval a : input.currentApprovals()) {
|
||||
if (a.getValue() != 0 && !a.isSubmit()) {
|
||||
if (a.getValue() != 0 && !a.isLegacySubmit()) {
|
||||
allApprovals.add(formatLabel(a.getLabel(), a.getValue(),
|
||||
a.getAccountId()));
|
||||
distinctApprovals.add(formatLabel(a.getLabel(), a.getValue()));
|
||||
|
||||
@@ -857,7 +857,7 @@ public class ChangeData {
|
||||
public Optional<PatchSetApproval> getSubmitApproval()
|
||||
throws OrmException {
|
||||
for (PatchSetApproval psa : currentApprovals()) {
|
||||
if (psa.isSubmit()) {
|
||||
if (psa.isLegacySubmit()) {
|
||||
return Optional.fromNullable(psa);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user