Option to create a new change for every commit not in target

One not-so-well-known feature of gerrit is that, you can set a
%base for the RevWalk in ReceiveCommits when pushing changes to
Gerrit. This makes it possible to push a commit for review and
override Gerrits default algorithm for creating new changes on
push to refs/for/*. For instance, one could submit a commit in
a private branch and, afterward, push the same commit to a
release branch.

Specifying the tip of the destination branch as the %base would
have an effect of creating a new change for every commit reachable
from the pushed commit and not reachable from the target branch.
This behavior seems to be wanted by some Gerrit users and is
implemented as a project config option by this change (although
it contradicts the Gerrit's philosophy of reviewing one commit once).
If a %base is explicitly set on during uploading changes,
new-change-for-all-not-in-target is ignored.

To avoid incidental pushes with merges,
new-change-for-all-not-in-target rejects uploads if changes
contain merge commits. In such cases to push a merge commit, you
need to explicitly set the %base parameter as described in
Uploading Changes / Selecting Merge Base documentation.

Bug: issue 1195
Change-Id: Ifa90184352c912885e52d2060356fcc039d0ef03
This commit is contained in:
Deniz Türkoglu
2014-09-08 17:02:48 +02:00
parent 64eb1e2f21
commit 52777270d9
19 changed files with 191 additions and 27 deletions

View File

@@ -41,6 +41,7 @@ public interface AdminConstants extends Constants {
String useContentMerge();
String useContributorAgreements();
String useSignedOffBy();
String createNewChangeForAllNotInTarget();
String requireChangeID();
String headingMaxObjectSizeLimit();
String headingGroupOptions();

View File

@@ -23,6 +23,7 @@ projectRepoBrowser = Repository Browser
useContentMerge = Automatically resolve conflicts
useContributorAgreements = Require a valid contributor agreement to upload
useSignedOffBy = Require <code>Signed-off-by</code> in commit message
createNewChangeForAllNotInTarget = Create a new change for every commit not in the target branch
requireChangeID = Require <code>Change-Id</code> in commit message
headingMaxObjectSizeLimit = Maximum Git object size limit
headingGroupOptions = Group Options

View File

@@ -79,6 +79,7 @@ public class ProjectInfoScreen extends ProjectScreen {
private ListBox submitType;
private ListBox state;
private ListBox contentMerge;
private ListBox newChangeForAllNotInTarget;
private NpTextBox maxObjectSizeLimit;
private Label effectiveMaxObjectSizeLimit;
private Map<String, Map<String, HasEnabled>> pluginConfigWidgets;
@@ -157,6 +158,7 @@ public class ProjectInfoScreen extends ProjectScreen {
state.setEnabled(isOwner);
submitType.setEnabled(isOwner);
setEnabledForUseContentMerge();
newChangeForAllNotInTarget.setEnabled(isOwner);
descTxt.setEnabled(isOwner);
contributorAgreements.setEnabled(isOwner);
signedOffBy.setEnabled(isOwner);
@@ -213,6 +215,10 @@ public class ProjectInfoScreen extends ProjectScreen {
saveEnabler.listenTo(contentMerge);
grid.add(Util.C.useContentMerge(), contentMerge);
newChangeForAllNotInTarget = newInheritedBooleanBox();
saveEnabler.listenTo(newChangeForAllNotInTarget);
grid.add(Util.C.createNewChangeForAllNotInTarget(), newChangeForAllNotInTarget);
requireChangeID = newInheritedBooleanBox();
saveEnabler.listenTo(requireChangeID);
grid.addHtml(Util.C.requireChangeID(), requireChangeID);
@@ -338,6 +344,7 @@ public class ProjectInfoScreen extends ProjectScreen {
setBool(contributorAgreements, result.use_contributor_agreements());
setBool(signedOffBy, result.use_signed_off_by());
setBool(contentMerge, result.use_content_merge());
setBool(newChangeForAllNotInTarget, result.create_new_change_for_all_not_in_target());
setBool(requireChangeID, result.require_change_id());
setSubmitType(result.submit_type());
setState(result.state());
@@ -569,7 +576,7 @@ public class ProjectInfoScreen extends ProjectScreen {
saveProject.setEnabled(false);
ProjectApi.setConfig(getProjectKey(), descTxt.getText().trim(),
getBool(contributorAgreements), getBool(contentMerge),
getBool(signedOffBy), getBool(requireChangeID),
getBool(signedOffBy), getBool(newChangeForAllNotInTarget), getBool(requireChangeID),
maxObjectSizeLimit.getText().trim(),
SubmitType.valueOf(submitType.getValue(submitType.getSelectedIndex())),
ProjectState.valueOf(state.getValue(state.getSelectedIndex())),