Move merge strategy classes to their own subpackage
Move the classes implementing the merge strategies into their own separate subpackage. Make members of CodeReviewCommit private and add getter/setter methods. Change-Id: Ice2faea73bcf86ec7edbdf69e4ac6f458d41757d
This commit is contained in:
@@ -27,7 +27,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
@@ -39,10 +39,10 @@ public class CodeReviewCommit extends RevCommit {
|
||||
* This value is only available on commits that have a PatchSet represented in
|
||||
* the code review system.
|
||||
*/
|
||||
PatchSet.Id patchsetId;
|
||||
private PatchSet.Id patchsetId;
|
||||
|
||||
/** Change control for the change owner. */
|
||||
ChangeControl control;
|
||||
private ChangeControl control;
|
||||
|
||||
/**
|
||||
* Ordinal position of this commit within the submit queue.
|
||||
@@ -56,7 +56,7 @@ public class CodeReviewCommit extends RevCommit {
|
||||
* <p>
|
||||
* Only valid if {@link #patchsetId} is not null.
|
||||
*/
|
||||
CommitMergeStatus statusCode;
|
||||
private CommitMergeStatus statusCode;
|
||||
|
||||
/** Commits which are missing ancestors of this commit. */
|
||||
List<CodeReviewCommit> missing;
|
||||
@@ -66,10 +66,26 @@ public class CodeReviewCommit extends RevCommit {
|
||||
}
|
||||
|
||||
public ChangeNotes notes() {
|
||||
return control.getNotes();
|
||||
return getControl().getNotes();
|
||||
}
|
||||
|
||||
void copyFrom(final CodeReviewCommit src) {
|
||||
public CommitMergeStatus getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(CommitMergeStatus statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public PatchSet.Id getPatchsetId() {
|
||||
return patchsetId;
|
||||
}
|
||||
|
||||
public void setPatchsetId(PatchSet.Id patchsetId) {
|
||||
this.patchsetId = patchsetId;
|
||||
}
|
||||
|
||||
public void copyFrom(final CodeReviewCommit src) {
|
||||
control = src.control;
|
||||
patchsetId = src.patchsetId;
|
||||
originalOrder = src.originalOrder;
|
||||
@@ -77,7 +93,15 @@ public class CodeReviewCommit extends RevCommit {
|
||||
missing = src.missing;
|
||||
}
|
||||
|
||||
Change change() {
|
||||
return control.getChange();
|
||||
public Change change() {
|
||||
return getControl().getChange();
|
||||
}
|
||||
|
||||
public ChangeControl getControl() {
|
||||
return control;
|
||||
}
|
||||
|
||||
public void setControl(ChangeControl control) {
|
||||
this.control = control;
|
||||
}
|
||||
}
|
||||
|
@@ -46,6 +46,8 @@ import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategy;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.git.validators.MergeValidationException;
|
||||
import com.google.gerrit.server.git.validators.MergeValidators;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
@@ -262,7 +264,7 @@ public class MergeOp {
|
||||
// missing are still attempted to be merged with another submit
|
||||
// strategy, retry to merge this commit in the next turn
|
||||
it.remove();
|
||||
commit.statusCode = null;
|
||||
commit.setStatusCode(null);
|
||||
commit.missing = null;
|
||||
toMergeNextTurn.put(submitType, commit);
|
||||
}
|
||||
@@ -334,7 +336,7 @@ public class MergeOp {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (missingCommit.patchsetId == null) {
|
||||
if (missingCommit.getPatchsetId() == null) {
|
||||
// The commit doesn't have a patch set, so it cannot be
|
||||
// submitted to the branch.
|
||||
//
|
||||
@@ -342,7 +344,7 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
if (!missingCommit.change().currentPatchSetId().equals(
|
||||
missingCommit.patchsetId)) {
|
||||
missingCommit.getPatchsetId())) {
|
||||
// If the missing commit is not the current patch set,
|
||||
// the change must be rebased to use the proper parent.
|
||||
//
|
||||
@@ -525,12 +527,12 @@ public class MergeOp {
|
||||
}
|
||||
|
||||
try {
|
||||
commit.control = changeControlFactory.controlFor(chg,
|
||||
identifiedUserFactory.create(chg.getOwner()));
|
||||
commit.setControl(changeControlFactory.controlFor(chg,
|
||||
identifiedUserFactory.create(chg.getOwner())));
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw new MergeException("Failed to validate changes", e);
|
||||
}
|
||||
commit.patchsetId = ps.getId();
|
||||
commit.setPatchsetId(ps.getId());
|
||||
commit.originalOrder = commitOrder++;
|
||||
commits.put(changeId, commit);
|
||||
|
||||
@@ -541,7 +543,7 @@ public class MergeOp {
|
||||
//
|
||||
try {
|
||||
if (rw.isMergedInto(commit, branchTip)) {
|
||||
commit.statusCode = CommitMergeStatus.ALREADY_MERGED;
|
||||
commit.setStatusCode(CommitMergeStatus.ALREADY_MERGED);
|
||||
try {
|
||||
setMerged(chg, null);
|
||||
} catch (OrmException e) {
|
||||
@@ -554,7 +556,7 @@ public class MergeOp {
|
||||
}
|
||||
}
|
||||
|
||||
final SubmitType submitType = getSubmitType(commit.control, ps);
|
||||
final SubmitType submitType = getSubmitType(commit.getControl(), ps);
|
||||
if (submitType == null) {
|
||||
commits.put(changeId,
|
||||
CodeReviewCommit.error(CommitMergeStatus.NO_SUBMIT_TYPE));
|
||||
@@ -625,7 +627,7 @@ public class MergeOp {
|
||||
|
||||
Account account = null;
|
||||
PatchSetApproval submitter = approvalsUtil.getSubmitter(
|
||||
db, mergeTip.notes(), mergeTip.patchsetId);
|
||||
db, mergeTip.notes(), mergeTip.getPatchsetId());
|
||||
if (submitter != null) {
|
||||
account = accountCache.get(submitter.getAccountId()).getAccount();
|
||||
}
|
||||
@@ -654,7 +656,7 @@ public class MergeOp {
|
||||
private void updateChangeStatus(final List<Change> submitted) {
|
||||
for (final Change c : submitted) {
|
||||
final CodeReviewCommit commit = commits.get(c.getId());
|
||||
final CommitMergeStatus s = commit != null ? commit.statusCode : null;
|
||||
final CommitMergeStatus s = commit != null ? commit.getStatusCode() : null;
|
||||
if (s == null) {
|
||||
// Shouldn't ever happen, but leave the change alone. We'll pick
|
||||
// it up on the next pass.
|
||||
@@ -765,12 +767,12 @@ public class MergeOp {
|
||||
m.append("The following dependency errors were found:\n");
|
||||
m.append("\n");
|
||||
for (CodeReviewCommit missingCommit : commit.missing) {
|
||||
if (missingCommit.patchsetId != null) {
|
||||
if (missingCommit.getPatchsetId() != null) {
|
||||
m.append("* Depends on patch set ");
|
||||
m.append(missingCommit.patchsetId.get());
|
||||
m.append(missingCommit.getPatchsetId().get());
|
||||
m.append(" of ");
|
||||
m.append(missingCommit.change().getKey().abbreviate());
|
||||
if (missingCommit.patchsetId.get() != missingCommit.change().currentPatchSetId().get()) {
|
||||
if (missingCommit.getPatchsetId().get() != missingCommit.change().currentPatchSetId().get()) {
|
||||
m.append(", however the current patch set is ");
|
||||
m.append(missingCommit.change().currentPatchSetId().get());
|
||||
}
|
||||
@@ -792,14 +794,13 @@ public class MergeOp {
|
||||
|
||||
private void loadChangeInfo(final CodeReviewCommit commit)
|
||||
throws NoSuchChangeException, OrmException {
|
||||
if (commit.control == null) {
|
||||
if (commit.getControl() == null) {
|
||||
List<PatchSet> matches =
|
||||
db.patchSets().byRevision(new RevId(commit.name())).toList();
|
||||
if (matches.size() == 1) {
|
||||
PatchSet ps = matches.get(0);
|
||||
commit.patchsetId = ps.getId();
|
||||
commit.control =
|
||||
changeControl(db.changes().get(ps.getId().getParentKey()));
|
||||
commit.setPatchsetId(ps.getId());
|
||||
commit.setControl(changeControl(db.changes().get(ps.getId().getParentKey())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -26,12 +26,12 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
class MergeSorter {
|
||||
public class MergeSorter {
|
||||
private final RevWalk rw;
|
||||
private final RevFlag canMergeFlag;
|
||||
private final Set<RevCommit> accepted;
|
||||
|
||||
MergeSorter(final RevWalk rw, final Set<RevCommit> alreadyAccepted,
|
||||
public MergeSorter(final RevWalk rw, final Set<RevCommit> alreadyAccepted,
|
||||
final RevFlag canMergeFlag) {
|
||||
this.rw = rw;
|
||||
this.canMergeFlag = canMergeFlag;
|
||||
@@ -59,7 +59,7 @@ class MergeSorter {
|
||||
// aren't permitted to merge at this time. Drop n.
|
||||
//
|
||||
if (n.missing == null) {
|
||||
n.statusCode = CommitMergeStatus.MISSING_DEPENDENCY;
|
||||
n.setStatusCode(CommitMergeStatus.MISSING_DEPENDENCY);
|
||||
n.missing = new ArrayList<CodeReviewCommit>();
|
||||
}
|
||||
n.missing.add((CodeReviewCommit) c);
|
||||
@@ -68,7 +68,7 @@ class MergeSorter {
|
||||
}
|
||||
}
|
||||
|
||||
if (n.statusCode == CommitMergeStatus.MISSING_DEPENDENCY) {
|
||||
if (n.getStatusCode() == CommitMergeStatus.MISSING_DEPENDENCY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -167,8 +167,8 @@ public class MergeUtil {
|
||||
});
|
||||
}
|
||||
|
||||
PatchSetApproval getSubmitter(CodeReviewCommit c) {
|
||||
return approvalsUtil.getSubmitter(db.get(), c.notes(), c.patchsetId);
|
||||
public PatchSetApproval getSubmitter(CodeReviewCommit c) {
|
||||
return approvalsUtil.getSubmitter(db.get(), c.notes(), c.getPatchsetId());
|
||||
}
|
||||
|
||||
public RevCommit createCherryPickFromCommit(Repository repo,
|
||||
@@ -226,7 +226,7 @@ public class MergeUtil {
|
||||
|
||||
final String siteUrl = urlProvider.get();
|
||||
if (siteUrl != null) {
|
||||
final String url = siteUrl + n.patchsetId.getParentKey().get();
|
||||
final String url = siteUrl + n.getPatchsetId().getParentKey().get();
|
||||
if (!contains(footers, REVIEWED_ON, url)) {
|
||||
msgbuf.append(REVIEWED_ON.getName());
|
||||
msgbuf.append(": ");
|
||||
@@ -313,9 +313,9 @@ public class MergeUtil {
|
||||
|
||||
private List<PatchSetApproval> safeGetApprovals(CodeReviewCommit n) {
|
||||
try {
|
||||
return approvalsUtil.byPatchSet(db.get(), n.notes(), n.patchsetId);
|
||||
return approvalsUtil.byPatchSet(db.get(), n.notes(), n.getPatchsetId());
|
||||
} catch (OrmException e) {
|
||||
log.error("Can't read approval records for " + n.patchsetId, e);
|
||||
log.error("Can't read approval records for " + n.getPatchsetId(), e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -540,7 +540,7 @@ public class MergeUtil {
|
||||
rw.markUninteresting(mergeTip);
|
||||
CodeReviewCommit failed;
|
||||
while ((failed = (CodeReviewCommit) rw.next()) != null) {
|
||||
failed.statusCode = failure;
|
||||
failed.setStatusCode(failure);
|
||||
}
|
||||
return failed;
|
||||
}
|
||||
@@ -557,7 +557,7 @@ public class MergeUtil {
|
||||
rw.markUninteresting(mergeTip);
|
||||
for (final RevCommit c : rw) {
|
||||
final CodeReviewCommit crc = (CodeReviewCommit) c;
|
||||
if (crc.patchsetId != null) {
|
||||
if (crc.getPatchsetId() != null) {
|
||||
merged.add(crc);
|
||||
}
|
||||
}
|
||||
@@ -589,7 +589,7 @@ public class MergeUtil {
|
||||
|
||||
CodeReviewCommit mergeResult =
|
||||
(CodeReviewCommit) rw.parseCommit(commit(inserter, mergeCommit));
|
||||
mergeResult.control = n.control;
|
||||
mergeResult.setControl(n.getControl());
|
||||
return mergeResult;
|
||||
}
|
||||
|
||||
@@ -706,8 +706,8 @@ public class MergeUtil {
|
||||
|
||||
CodeReviewCommit c;
|
||||
while ((c = (CodeReviewCommit) rw.next()) != null) {
|
||||
if (c.patchsetId != null) {
|
||||
c.statusCode = CommitMergeStatus.CLEAN_MERGE;
|
||||
if (c.getPatchsetId() != null) {
|
||||
c.setStatusCode(CommitMergeStatus.CLEAN_MERGE);
|
||||
if (submitApproval == null) {
|
||||
submitApproval = getSubmitter(c);
|
||||
}
|
||||
|
@@ -27,20 +27,20 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
class RebaseSorter {
|
||||
public class RebaseSorter {
|
||||
|
||||
private final RevWalk rw;
|
||||
private final RevFlag canMergeFlag;
|
||||
private final Set<RevCommit> accepted;
|
||||
|
||||
RebaseSorter(final RevWalk rw, final Set<RevCommit> alreadyAccepted,
|
||||
public RebaseSorter(final RevWalk rw, final Set<RevCommit> alreadyAccepted,
|
||||
final RevFlag canMergeFlag) {
|
||||
this.rw = rw;
|
||||
this.canMergeFlag = canMergeFlag;
|
||||
this.accepted = alreadyAccepted;
|
||||
}
|
||||
|
||||
List<CodeReviewCommit> sort(Collection<CodeReviewCommit> incoming)
|
||||
public List<CodeReviewCommit> sort(Collection<CodeReviewCommit> incoming)
|
||||
throws IOException {
|
||||
final List<CodeReviewCommit> sorted = new ArrayList<CodeReviewCommit>();
|
||||
final Set<CodeReviewCommit> sort = new HashSet<CodeReviewCommit>(incoming);
|
||||
@@ -61,7 +61,7 @@ class RebaseSorter {
|
||||
// aren't permitted to merge at this time. Drop n.
|
||||
//
|
||||
if (n.missing == null) {
|
||||
n.statusCode = CommitMergeStatus.MISSING_DEPENDENCY;
|
||||
n.setStatusCode(CommitMergeStatus.MISSING_DEPENDENCY);
|
||||
n.missing = new ArrayList<CodeReviewCommit>();
|
||||
}
|
||||
n.missing.add(c);
|
||||
@@ -70,7 +70,7 @@ class RebaseSorter {
|
||||
}
|
||||
}
|
||||
|
||||
if (n.statusCode == CommitMergeStatus.MISSING_DEPENDENCY) {
|
||||
if (n.getStatusCode() == CommitMergeStatus.MISSING_DEPENDENCY) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -216,8 +216,9 @@ public class SubmoduleOp {
|
||||
for (final Change chg : submitted) {
|
||||
final CodeReviewCommit c = commits.get(chg.getId());
|
||||
if (c != null
|
||||
&& (c.statusCode == CommitMergeStatus.CLEAN_MERGE
|
||||
|| c.statusCode == CommitMergeStatus.CLEAN_PICK || c.statusCode == CommitMergeStatus.CLEAN_REBASE)) {
|
||||
&& (c.getStatusCode() == CommitMergeStatus.CLEAN_MERGE
|
||||
|| c.getStatusCode() == CommitMergeStatus.CLEAN_PICK
|
||||
|| c.getStatusCode() == CommitMergeStatus.CLEAN_REBASE)) {
|
||||
msgbuf += "\n";
|
||||
msgbuf += c.getFullMessage();
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -24,6 +24,9 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CommitMergeStatus;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
@@ -69,13 +72,13 @@ public class CherryPick extends SubmitStrategy {
|
||||
// create the branch.
|
||||
//
|
||||
newMergeTip = n;
|
||||
n.statusCode = CommitMergeStatus.CLEAN_MERGE;
|
||||
n.setStatusCode(CommitMergeStatus.CLEAN_MERGE);
|
||||
|
||||
} else if (n.getParentCount() == 0) {
|
||||
// Refuse to merge a root commit into an existing branch,
|
||||
// we cannot obtain a delta for the cherry-pick to apply.
|
||||
//
|
||||
n.statusCode = CommitMergeStatus.CANNOT_CHERRY_PICK_ROOT;
|
||||
n.setStatusCode(CommitMergeStatus.CANNOT_CHERRY_PICK_ROOT);
|
||||
|
||||
} else if (n.getParentCount() == 1) {
|
||||
// If there is only one parent, a cherry-pick can be done by
|
||||
@@ -86,9 +89,9 @@ public class CherryPick extends SubmitStrategy {
|
||||
newMergeTip = writeCherryPickCommit(mergeTip, n);
|
||||
|
||||
if (newMergeTip != null) {
|
||||
newCommits.put(newMergeTip.patchsetId.getParentKey(), newMergeTip);
|
||||
newCommits.put(newMergeTip.getPatchsetId().getParentKey(), newMergeTip);
|
||||
} else {
|
||||
n.statusCode = CommitMergeStatus.PATH_CONFLICT;
|
||||
n.setStatusCode(CommitMergeStatus.PATH_CONFLICT);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -177,7 +180,7 @@ public class CherryPick extends SubmitStrategy {
|
||||
|
||||
final List<PatchSetApproval> approvals = Lists.newArrayList();
|
||||
for (PatchSetApproval a
|
||||
: args.approvalsUtil.byPatchSet(args.db, n.notes(), n.patchsetId)) {
|
||||
: args.approvalsUtil.byPatchSet(args.db, n.notes(), n.getPatchsetId())) {
|
||||
approvals.add(new PatchSetApproval(ps.getId(), a));
|
||||
}
|
||||
// TODO(dborowitz): This doesn't copy labels in the notedb. We should
|
||||
@@ -203,10 +206,9 @@ public class CherryPick extends SubmitStrategy {
|
||||
gitRefUpdated.fire(n.change().getProject(), ru);
|
||||
|
||||
newCommit.copyFrom(n);
|
||||
newCommit.statusCode = CommitMergeStatus.CLEAN_PICK;
|
||||
newCommit.control =
|
||||
args.changeControlFactory.controlFor(n.change(), cherryPickUser);
|
||||
newCommits.put(newCommit.patchsetId.getParentKey(), newCommit);
|
||||
newCommit.setStatusCode(CommitMergeStatus.CLEAN_PICK);
|
||||
newCommit.setControl(args.changeControlFactory.controlFor(n.change(), cherryPickUser));
|
||||
newCommits.put(newCommit.getPatchsetId().getParentKey(), newCommit);
|
||||
setRefLogIdent(submitAudit);
|
||||
return newCommit;
|
||||
}
|
@@ -12,9 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CommitMergeStatus;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,7 +36,7 @@ public class FastForwardOnly extends SubmitStrategy {
|
||||
|
||||
while (!toMerge.isEmpty()) {
|
||||
final CodeReviewCommit n = toMerge.remove(0);
|
||||
n.statusCode = CommitMergeStatus.NOT_FAST_FORWARD;
|
||||
n.setStatusCode(CommitMergeStatus.NOT_FAST_FORWARD);
|
||||
}
|
||||
|
||||
final PatchSetApproval submitApproval =
|
@@ -12,9 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
|
||||
import java.util.List;
|
||||
|
@@ -12,9 +12,11 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
|
||||
import java.util.List;
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -22,6 +22,10 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.change.PatchSetInserter.ValidatePolicy;
|
||||
import com.google.gerrit.server.changedetail.PathConflictException;
|
||||
import com.google.gerrit.server.changedetail.RebaseChange;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.CommitMergeStatus;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.RebaseSorter;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
@@ -66,19 +70,19 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
// create the branch.
|
||||
//
|
||||
newMergeTip = n;
|
||||
n.statusCode = CommitMergeStatus.CLEAN_MERGE;
|
||||
n.setStatusCode(CommitMergeStatus.CLEAN_MERGE);
|
||||
|
||||
} else if (n.getParentCount() == 0) {
|
||||
// Refuse to merge a root commit into an existing branch,
|
||||
// we cannot obtain a delta for the rebase to apply.
|
||||
//
|
||||
n.statusCode = CommitMergeStatus.CANNOT_REBASE_ROOT;
|
||||
n.setStatusCode(CommitMergeStatus.CANNOT_REBASE_ROOT);
|
||||
|
||||
} else if (n.getParentCount() == 1) {
|
||||
if (args.mergeUtil.canFastForward(
|
||||
args.mergeSorter, newMergeTip, args.rw, n)) {
|
||||
newMergeTip = n;
|
||||
n.statusCode = CommitMergeStatus.CLEAN_MERGE;
|
||||
n.setStatusCode(CommitMergeStatus.CLEAN_MERGE);
|
||||
|
||||
} else {
|
||||
try {
|
||||
@@ -86,7 +90,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
args.mergeUtil.getSubmitter(n).getAccountId());
|
||||
final PatchSet newPatchSet =
|
||||
rebaseChange.rebase(args.repo, args.rw, args.inserter,
|
||||
n.patchsetId, n.change(), uploader,
|
||||
n.getPatchsetId(), n.change(), uploader,
|
||||
newMergeTip, args.mergeUtil, committerIdent,
|
||||
false, false, ValidatePolicy.NONE);
|
||||
|
||||
@@ -95,7 +99,7 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
// describes the change being submitted.
|
||||
List<PatchSetApproval> approvals = Lists.newArrayList();
|
||||
for (PatchSetApproval a : args.approvalsUtil.byPatchSet(
|
||||
args.db, n.notes(), n.patchsetId)) {
|
||||
args.db, n.notes(), n.getPatchsetId())) {
|
||||
approvals.add(new PatchSetApproval(newPatchSet.getId(), a));
|
||||
}
|
||||
args.db.patchSetApprovals().insert(approvals);
|
||||
@@ -106,14 +110,13 @@ public class RebaseIfNecessary extends SubmitStrategy {
|
||||
n.change().setCurrentPatchSet(
|
||||
patchSetInfoFactory.get(newMergeTip, newPatchSet.getId()));
|
||||
newMergeTip.copyFrom(n);
|
||||
newMergeTip.control =
|
||||
args.changeControlFactory.controlFor(n.change(), uploader);
|
||||
newMergeTip.patchsetId = newPatchSet.getId();
|
||||
newMergeTip.statusCode = CommitMergeStatus.CLEAN_REBASE;
|
||||
newMergeTip.setControl(args.changeControlFactory.controlFor(n.change(), uploader));
|
||||
newMergeTip.setPatchsetId(newPatchSet.getId());
|
||||
newMergeTip.setStatusCode(CommitMergeStatus.CLEAN_REBASE);
|
||||
newCommits.put(newPatchSet.getId().getParentKey(), newMergeTip);
|
||||
setRefLogIdent(args.mergeUtil.getSubmitter(n));
|
||||
} catch (PathConflictException e) {
|
||||
n.statusCode = CommitMergeStatus.PATH_CONFLICT;
|
||||
n.setStatusCode(CommitMergeStatus.PATH_CONFLICT);
|
||||
} catch (NoSuchChangeException | OrmException | IOException
|
||||
| InvalidChangeOperationException e) {
|
||||
throw new MergeException("Cannot rebase " + n.name(), e);
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -21,6 +21,10 @@ import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.MergeSorter;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.git;
|
||||
package com.google.gerrit.server.git.strategy;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||
@@ -22,6 +22,8 @@ import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.changedetail.RebaseChange;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoFactory;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
@@ -35,7 +35,7 @@ import com.google.gerrit.server.config.AllProjectsName;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.TrackingFooters;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategyFactory;
|
||||
import com.google.gerrit.server.index.ChangeIndex;
|
||||
import com.google.gerrit.server.index.IndexCollection;
|
||||
import com.google.gerrit.server.index.Schema;
|
||||
|
@@ -22,7 +22,7 @@ import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.git.CodeReviewCommit;
|
||||
import com.google.gerrit.server.git.MergeException;
|
||||
import com.google.gerrit.server.git.SubmitStrategy;
|
||||
import com.google.gerrit.server.git.strategy.SubmitStrategy;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
|
Reference in New Issue
Block a user