Refactor MergeOp: reduce number of member variables, make names consistent

MergeOp has many member variables to hold the current state of the merge
operation. They are read and updated in many methods which makes it
difficult to understand the pre and post conditions for a method.

Remove some of the member variables and instead have explicit method
input parameters and return values.

Also do a few renames to make the naming consistent with other classes.

Change-Id: I5e33c38cc928e32d8047f4aa9d24fb857b41049a
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-09-25 15:42:03 +02:00
parent 7e136c540a
commit 7d9ae387f4
2 changed files with 47 additions and 35 deletions

View File

@@ -28,14 +28,14 @@ import java.util.Set;
class MergeSorter {
private final RevWalk rw;
private final RevFlag CAN_MERGE;
private final RevFlag canMergeFlag;
private final Set<RevCommit> accepted;
MergeSorter(final RevWalk walk, final Set<RevCommit> alreadyAccepted,
final RevFlag flagCAN_MERGE) {
rw = walk;
CAN_MERGE = flagCAN_MERGE;
accepted = alreadyAccepted;
MergeSorter(final RevWalk rw, final Set<RevCommit> alreadyAccepted,
final RevFlag canMergeFlag) {
this.rw = rw;
this.canMergeFlag = canMergeFlag;
this.accepted = alreadyAccepted;
}
Collection<CodeReviewCommit> sort(final Collection<CodeReviewCommit> incoming)
@@ -45,7 +45,7 @@ class MergeSorter {
while (!sort.isEmpty()) {
final CodeReviewCommit n = removeOne(sort);
rw.resetRetain(CAN_MERGE);
rw.resetRetain(canMergeFlag);
rw.markStart(n);
for (RevCommit c : accepted) {
rw.markUninteresting(c);
@@ -54,7 +54,7 @@ class MergeSorter {
RevCommit c;
final RevCommitList<RevCommit> contents = new RevCommitList<RevCommit>();
while ((c = rw.next()) != null) {
if (!c.has(CAN_MERGE)) {
if (!c.has(canMergeFlag)) {
// We cannot merge n as it would bring something we
// aren't permitted to merge at this time. Drop n.
//