aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java157
1 files changed, 86 insertions, 71 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
index 9dc33b5ad5..0fa11f2cbb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeResult.java
@@ -1,45 +1,12 @@
/*
* Copyright (C) 2010, Stefan Lay <stefan.lay@sap.com>
- * Copyright (C) 2010-2012, Christian Halstrick <christian.halstrick@sap.com>
- * and other copyright owners as documented in the project's IP log.
+ * Copyright (C) 2010-2012, Christian Halstrick <christian.halstrick@sap.com> and others
*
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Distribution License v1.0 which
- * accompanies this distribution, is reproduced below, and is
- * available at http://www.eclipse.org/org/documents/edl-v10.php
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
*
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- *
- * - Neither the name of the Eclipse Foundation, Inc. nor the
- * names of its contributors may be used to endorse or promote
- * products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.api;
@@ -53,11 +20,10 @@ import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.merge.MergeChunk;
import org.eclipse.jgit.merge.MergeChunk.ConflictState;
import org.eclipse.jgit.merge.MergeStrategy;
-import org.eclipse.jgit.merge.ResolveMerger;
import org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason;
/**
- * Encapsulates the result of a {@link MergeCommand}.
+ * Encapsulates the result of a {@link org.eclipse.jgit.api.MergeCommand}.
*/
public class MergeResult {
@@ -65,11 +31,13 @@ public class MergeResult {
* The status the merge resulted in.
*/
public enum MergeStatus {
- /** */
+ /**
+ * Merge is a fast-forward
+ */
FAST_FORWARD {
@Override
public String toString() {
- return "Fast-forward";
+ return "Fast-forward"; //$NON-NLS-1$
}
@Override
@@ -78,12 +46,14 @@ public class MergeResult {
}
},
/**
+ * Merge is a fast-forward, squashed
+ *
* @since 2.0
*/
FAST_FORWARD_SQUASHED {
@Override
public String toString() {
- return "Fast-forward-squashed";
+ return "Fast-forward-squashed"; //$NON-NLS-1$
}
@Override
@@ -91,11 +61,13 @@ public class MergeResult {
return true;
}
},
- /** */
+ /**
+ * Already up to date, merge was a no-op
+ */
ALREADY_UP_TO_DATE {
@Override
public String toString() {
- return "Already-up-to-date";
+ return "Already-up-to-date"; //$NON-NLS-1$
}
@Override
@@ -103,11 +75,13 @@ public class MergeResult {
return true;
}
},
- /** */
+ /**
+ * Merge failed
+ */
FAILED {
@Override
public String toString() {
- return "Failed";
+ return "Failed"; //$NON-NLS-1$
}
@Override
@@ -115,11 +89,13 @@ public class MergeResult {
return false;
}
},
- /** */
+ /**
+ * Merged
+ */
MERGED {
@Override
public String toString() {
- return "Merged";
+ return "Merged"; //$NON-NLS-1$
}
@Override
@@ -128,12 +104,14 @@ public class MergeResult {
}
},
/**
+ * Merged, squashed, not updating HEAD
+ *
* @since 2.0
*/
MERGED_SQUASHED {
@Override
public String toString() {
- return "Merged-squashed";
+ return "Merged-squashed"; //$NON-NLS-1$
}
@Override
@@ -142,12 +120,14 @@ public class MergeResult {
}
},
/**
+ * Merged, squashed, not committed
+ *
* @since 3.0
*/
MERGED_SQUASHED_NOT_COMMITTED {
@Override
public String toString() {
- return "Merged-squashed-not-committed";
+ return "Merged-squashed-not-committed"; //$NON-NLS-1$
}
@Override
@@ -155,11 +135,13 @@ public class MergeResult {
return true;
}
},
- /** */
+ /**
+ * Merge raised conflicts to be resolved
+ */
CONFLICTING {
@Override
public String toString() {
- return "Conflicting";
+ return "Conflicting"; //$NON-NLS-1$
}
@Override
@@ -168,12 +150,14 @@ public class MergeResult {
}
},
/**
+ * Merge was aborted
+ *
* @since 2.2
*/
ABORTED {
@Override
public String toString() {
- return "Aborted";
+ return "Aborted"; //$NON-NLS-1$
}
@Override
@@ -182,11 +166,14 @@ public class MergeResult {
}
},
/**
+ * Merged, not committed
+ *
* @since 3.0
**/
MERGED_NOT_COMMITTED {
+ @Override
public String toString() {
- return "Merged-not-committed";
+ return "Merged-not-committed"; //$NON-NLS-1$
}
@Override
@@ -194,11 +181,11 @@ public class MergeResult {
return true;
}
},
- /** */
+ /** Not yet supported */
NOT_SUPPORTED {
@Override
public String toString() {
- return "Not-yet-supported";
+ return "Not-yet-supported"; //$NON-NLS-1$
}
@Override
@@ -212,8 +199,9 @@ public class MergeResult {
* files (i.e. local modifications prevent checkout of files).
*/
CHECKOUT_CONFLICT {
+ @Override
public String toString() {
- return "Checkout Conflict";
+ return "Checkout Conflict"; //$NON-NLS-1$
}
@Override
@@ -223,6 +211,8 @@ public class MergeResult {
};
/**
+ * Whether the merge was successful
+ *
* @return whether the status indicates a successful result
*/
public abstract boolean isSuccessful();
@@ -247,6 +237,8 @@ public class MergeResult {
private List<String> checkoutConflicts;
/**
+ * Constructor for MergeResult.
+ *
* @param newHead
* the object the head points at after the merge
* @param base
@@ -258,10 +250,10 @@ public class MergeResult {
* @param mergeStatus
* the status the merge resulted in
* @param mergeStrategy
- * the used {@link MergeStrategy}
+ * the used {@link org.eclipse.jgit.merge.MergeStrategy}
* @param lowLevelResults
* merge results as returned by
- * {@link ResolveMerger#getMergeResults()}
+ * {@link org.eclipse.jgit.merge.ResolveMerger#getMergeResults()}
* @since 2.0
*/
public MergeResult(ObjectId newHead, ObjectId base,
@@ -273,6 +265,8 @@ public class MergeResult {
}
/**
+ * Constructor for MergeResult.
+ *
* @param newHead
* the object the head points at after the merge
* @param base
@@ -284,9 +278,10 @@ public class MergeResult {
* @param mergeStatus
* the status the merge resulted in
* @param mergeStrategy
- * the used {@link MergeStrategy}
+ * the used {@link org.eclipse.jgit.merge.MergeStrategy}
* @param lowLevelResults
- * merge results as returned by {@link ResolveMerger#getMergeResults()}
+ * merge results as returned by
+ * {@link org.eclipse.jgit.merge.ResolveMerger#getMergeResults()}
* @param description
* a user friendly description of the merge result
*/
@@ -300,6 +295,8 @@ public class MergeResult {
}
/**
+ * Constructor for MergeResult.
+ *
* @param newHead
* the object the head points at after the merge
* @param base
@@ -311,13 +308,13 @@ public class MergeResult {
* @param mergeStatus
* the status the merge resulted in
* @param mergeStrategy
- * the used {@link MergeStrategy}
+ * the used {@link org.eclipse.jgit.merge.MergeStrategy}
* @param lowLevelResults
* merge results as returned by
- * {@link ResolveMerger#getMergeResults()}
+ * {@link org.eclipse.jgit.merge.ResolveMerger#getMergeResults()}
* @param failingPaths
* list of paths causing this merge to fail as returned by
- * {@link ResolveMerger#getFailingPaths()}
+ * {@link org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()}
* @param description
* a user friendly description of the merge result
*/
@@ -352,6 +349,8 @@ public class MergeResult {
}
/**
+ * Get the object the head points at after the merge
+ *
* @return the object the head points at after the merge
*/
public ObjectId getNewHead() {
@@ -359,6 +358,8 @@ public class MergeResult {
}
/**
+ * Get the merge status
+ *
* @return the status the merge resulted in
*/
public MergeStatus getMergeStatus() {
@@ -366,6 +367,8 @@ public class MergeResult {
}
/**
+ * Get the commits which have been merged
+ *
* @return all the commits which have been merged together
*/
public ObjectId[] getMergedCommits() {
@@ -373,6 +376,8 @@ public class MergeResult {
}
/**
+ * Get the common base
+ *
* @return base the common base which was used to produce a content-merge.
* May be <code>null</code> if the merge-result was produced without
* computing a common base
@@ -400,6 +405,8 @@ public class MergeResult {
}
/**
+ * Set conflicts
+ *
* @param conflicts
* the conflicts to set
*/
@@ -408,25 +415,32 @@ public class MergeResult {
}
/**
+ * Add a conflict
+ *
* @param path
+ * path of the file to add a conflict for
* @param conflictingRanges
* the conflicts to set
*/
public void addConflict(String path, int[][] conflictingRanges) {
if (conflicts == null)
- conflicts = new HashMap<String, int[][]>();
+ conflicts = new HashMap<>();
conflicts.put(path, conflictingRanges);
}
/**
+ * Add a conflict
+ *
* @param path
+ * path of the file to add a conflict for
* @param lowLevelResult
+ * a {@link org.eclipse.jgit.merge.MergeResult}
*/
public void addConflict(String path, org.eclipse.jgit.merge.MergeResult<?> lowLevelResult) {
if (!lowLevelResult.containsConflicts())
return;
if (conflicts == null)
- conflicts = new HashMap<String, int[][]>();
+ conflicts = new HashMap<>();
int nrOfConflicts = 0;
// just counting
for (MergeChunk mergeChunk : lowLevelResult) {
@@ -460,9 +474,10 @@ public class MergeResult {
/**
* Returns information about the conflicts which occurred during a
- * {@link MergeCommand}. The returned value maps the path of a conflicting
- * file to a two-dimensional int-array of line-numbers telling where in the
- * file conflict markers for which merged commit can be found.
+ * {@link org.eclipse.jgit.api.MergeCommand}. The returned value maps the
+ * path of a conflicting file to a two-dimensional int-array of line-numbers
+ * telling where in the file conflict markers for which merged commit can be
+ * found.
* <p>
* If the returned value contains a mapping "path"-&gt;[x][y]=z then this
* means
@@ -503,7 +518,7 @@ public class MergeResult {
/**
* Returns a list of paths causing this merge to fail as returned by
- * {@link ResolveMerger#getFailingPaths()}
+ * {@link org.eclipse.jgit.merge.ResolveMerger#getFailingPaths()}
*
* @return the list of paths causing this merge to fail or <code>null</code>
* if no failure occurred