Merge feature 'Control submit type from Prolog'

* Control submit type from Prolog:
  Support controlling the submit type for changes from Prolog
  Remove unnecessary Prolog-to-Java conversion from submit filters
  Use locate_helper to replace locate_* predicates
  ChangeControl: Extract Prolog submit rule evaluation to its own method
  Display submit type in the change info block
  Support changes with different submit types in MergeOp
  Make submit strategies re-executeable
  Refactor MergeOp: reduce number of member variables, make names consistent
  Refactor MergeOp: implement each submit strategy in an own class
  Refactor MergeOp: extract utility methods into MergeUtil class

Change-Id: I71d4f5757ab96b5eb8456972398a7bb9fa2a7d4c
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-10-15 13:46:38 +02:00
26 changed files with 1946 additions and 841 deletions

View File

@@ -95,6 +95,7 @@ public interface ChangeConstants extends Constants {
String changeInfoBlockUploaded();
String changeInfoBlockUpdated();
String changeInfoBlockStatus();
String changeInfoBlockSubmitType();
String changePermalink();
String changeInfoBlockCanMerge();
String changeInfoBlockCanMergeYes();

View File

@@ -72,6 +72,7 @@ changeInfoBlockTopic = Topic
changeInfoBlockUploaded = Uploaded
changeInfoBlockUpdated = Updated
changeInfoBlockStatus = Status
changeInfoBlockSubmitType = Submit Type
changePermalink = Permalink
changeInfoBlockCanMerge = Can Merge
changeInfoBlockCanMergeYes = Yes

View File

@@ -15,8 +15,10 @@
package com.google.gerrit.client.changes;
import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSetInfo;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
@@ -36,8 +38,8 @@ public class ChangeDescriptionBlock extends Composite {
}
public void display(Change chg, Boolean starred, PatchSetInfo info,
final AccountInfoCache acc) {
infoBlock.display(chg, acc);
final AccountInfoCache acc, SubmitTypeRecord submitTypeRecord) {
infoBlock.display(chg, acc, submitTypeRecord);
messageBlock.display(chg.getId(), starred, info.getMessage());
}
}

View File

@@ -21,6 +21,7 @@ import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ProjectLink;
import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.common.data.SubmitTypeRecord;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gwt.user.client.ui.Composite;
@@ -36,9 +37,10 @@ public class ChangeInfoBlock extends Composite {
private static final int R_TOPIC = 4;
private static final int R_UPLOADED = 5;
private static final int R_UPDATED = 6;
private static final int R_STATUS = 7;
private static final int R_MERGE_TEST = 8;
private static final int R_CNT = 9;
private static final int R_SUBMIT_TYPE = 7;
private static final int R_STATUS = 8;
private static final int R_MERGE_TEST = 9;
private static final int R_CNT = 10;
private final Grid table;
@@ -59,6 +61,7 @@ public class ChangeInfoBlock extends Composite {
initRow(R_UPLOADED, Util.C.changeInfoBlockUploaded());
initRow(R_UPDATED, Util.C.changeInfoBlockUpdated());
initRow(R_STATUS, Util.C.changeInfoBlockStatus());
initRow(R_SUBMIT_TYPE, Util.C.changeInfoBlockSubmitType());
if (Gerrit.getConfig().testChangeMerge()) {
initRow(R_MERGE_TEST, Util.C.changeInfoBlockCanMerge());
}
@@ -77,7 +80,8 @@ public class ChangeInfoBlock extends Composite {
table.getCellFormatter().addStyleName(row, 0, Gerrit.RESOURCES.css().header());
}
public void display(final Change chg, final AccountInfoCache acc) {
public void display(final Change chg, final AccountInfoCache acc,
SubmitTypeRecord submitTypeRecord) {
final Branch.NameKey dst = chg.getDest();
CopyableLabel changeIdLabel =
@@ -94,6 +98,14 @@ public class ChangeInfoBlock extends Composite {
table.setText(R_UPLOADED, 1, mediumFormat(chg.getCreatedOn()));
table.setText(R_UPDATED, 1, mediumFormat(chg.getLastUpdatedOn()));
table.setText(R_STATUS, 1, Util.toLongString(chg.getStatus()));
String submitType;
if (submitTypeRecord.status == SubmitTypeRecord.Status.OK) {
submitType = com.google.gerrit.client.admin.Util
.toLongString(submitTypeRecord.type);
} else {
submitType = submitTypeRecord.status.name();
}
table.setText(R_SUBMIT_TYPE, 1, submitType);
final Change.Status status = chg.getStatus();
if (Gerrit.getConfig().testChangeMerge()) {
if (status.equals(Change.Status.NEW) || status.equals(Change.Status.DRAFT)) {

View File

@@ -282,7 +282,7 @@ public class ChangeScreen extends Screen
descriptionBlock.display(detail.getChange(),
detail.isStarred(),
detail.getCurrentPatchSetDetail().getInfo(),
detail.getAccounts());
detail.getAccounts(), detail.getSubmitTypeRecord());
dependsOn.display(detail.getDependsOn());
neededBy.display(detail.getNeededBy());
approvals.display(detail);

View File

@@ -274,7 +274,8 @@ public class PublishCommentScreen extends AccountScreen implements
private void display(final PatchSetPublishDetail r) {
setPageTitle(Util.M.publishComments(r.getChange().getKey().abbreviate(),
patchSetId.get()));
descBlock.display(r.getChange(), null, r.getPatchSetInfo(), r.getAccounts());
descBlock.display(r.getChange(), null, r.getPatchSetInfo(), r.getAccounts(),
r.getSubmitTypeRecord());
if (r.getChange().getStatus().isOpen()) {
initApprovals(r, approvalPanel);