Do not modify git repository when checking if a change is mergeable

If testing of mergeability of changes is enabled (see changeMerge.test
config parameter) the merge algorithm is executed without updating
the destination branch and the change status. However running the merge
algorithm creates new objects and even commits in the git repository.
The created objects/commits are never used and it's just waste to
create them and to have them.

Rewrite the mergeability test so that it is a read-only operation and
the git repository is not modified.

If CHERRY_PICK is chosen as submit type the merge algorithm also
creates a new patch set for the commit that was created by the cherry
pick. When testing the mergeability creating the new patch set
currently fails with an NullPointerException since the code trys to set
the submitter as uploader of the new patch set, but there is no
submitter when the mergeability is tested.

Change-Id: I613f45e7d173b33db3e400fba461bb94c86320ec
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-09-06 15:16:15 +02:00
parent ba02b61480
commit a085d501c0
7 changed files with 175 additions and 23 deletions

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.git;
import static com.google.gerrit.server.git.MergeUtil.canFastForward;
import static com.google.gerrit.server.git.MergeUtil.canMerge;
import static com.google.gerrit.server.git.MergeUtil.getFirstFastForward;
import static com.google.gerrit.server.git.MergeUtil.markCleanMerges;
import static com.google.gerrit.server.git.MergeUtil.mergeOneCommit;
@@ -52,4 +54,12 @@ public class MergeIfNecessary extends SubmitStrategy {
return newMergeTip;
}
@Override
public boolean dryRun(final CodeReviewCommit mergeTip,
final CodeReviewCommit toMerge) throws MergeException {
return canFastForward(args.mergeSorter, mergeTip, args.rw, toMerge)
|| canMerge(args.mergeSorter, args.repo, args.useContentMerge,
mergeTip, toMerge);
}
}