diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java index 18b0ad92c8..079db4a07f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/MergeFormatter.java @@ -22,6 +22,7 @@ import org.eclipse.jgit.diff.RawText; * A class to convert merge results into a Git conformant textual presentation */ public class MergeFormatter { + /** * Formats the results of a merge of {@link org.eclipse.jgit.diff.RawText} * objects in a Git conformant way. This method also assumes that the @@ -39,27 +40,24 @@ public class MergeFormatter { * name. This name is following the "<<<<<<< * " or ">>>>>>> " conflict markers. The * names for the sequences are given in this list - * @param charsetName - * the name of the character set used when writing conflict - * metadata + * @param charset + * the character set used when writing conflict metadata * @throws java.io.IOException - * @deprecated Use - * {@link #formatMerge(OutputStream, MergeResult, List, Charset)} - * instead. + * if an IO error occurred + * @since 5.2 */ - @Deprecated public void formatMerge(OutputStream out, MergeResult<RawText> res, - List<String> seqName, String charsetName) throws IOException { - formatMerge(out, res, seqName, Charset.forName(charsetName)); + List<String> seqName, Charset charset) throws IOException { + new MergeFormatterPass(out, res, seqName, charset).formatMerge(); } /** * Formats the results of a merge of {@link org.eclipse.jgit.diff.RawText} - * objects in a Git conformant way. This method also assumes that the - * {@link org.eclipse.jgit.diff.RawText} objects being merged are line - * oriented files which use LF as delimiter. This method will also use LF to - * separate chunks and conflict metadata, therefore it fits only to texts - * that are LF-separated lines. + * objects in a Git conformant way using diff3 style. This method also + * assumes that the {@link org.eclipse.jgit.diff.RawText} objects being + * merged are line oriented files which use LF as delimiter. This method + * will also use LF to separate chunks and conflict metadata, therefore it + * fits only to texts that are LF-separated lines. * * @param out * the output stream where to write the textual presentation @@ -68,16 +66,18 @@ public class MergeFormatter { * @param seqName * When a conflict is reported each conflicting range will get a * name. This name is following the "<<<<<<< - * " or ">>>>>>> " conflict markers. The - * names for the sequences are given in this list + * ", "|||||||" or ">>>>>>> " conflict + * markers. The names for the sequences are given in this list * @param charset * the character set used when writing conflict metadata * @throws java.io.IOException - * @since 5.2 + * if an IO error occurred + * @since 6.7 */ - public void formatMerge(OutputStream out, MergeResult<RawText> res, - List<String> seqName, Charset charset) throws IOException { - new MergeFormatterPass(out, res, seqName, charset).formatMerge(); + public void formatMergeDiff3(OutputStream out, + MergeResult<RawText> res, List<String> seqName, Charset charset) + throws IOException { + new MergeFormatterPass(out, res, seqName, charset, true).formatMerge(); } /** @@ -98,27 +98,29 @@ public class MergeFormatter { * the name ranges from ours should get * @param theirsName * the name ranges from theirs should get - * @param charsetName - * the name of the character set used when writing conflict - * metadata + * @param charset + * the character set used when writing conflict metadata * @throws java.io.IOException - * @deprecated use - * {@link #formatMerge(OutputStream, MergeResult, String, String, String, Charset)} - * instead. + * if an IO error occurred + * @since 5.2 */ - @Deprecated + @SuppressWarnings("unchecked") public void formatMerge(OutputStream out, MergeResult res, String baseName, - String oursName, String theirsName, String charsetName) throws IOException { - formatMerge(out, res, baseName, oursName, theirsName, - Charset.forName(charsetName)); + String oursName, String theirsName, Charset charset) + throws IOException { + List<String> names = new ArrayList<>(3); + names.add(baseName); + names.add(oursName); + names.add(theirsName); + formatMerge(out, res, names, charset); } /** - * Formats the results of a merge of exactly two - * {@link org.eclipse.jgit.diff.RawText} objects in a Git conformant way. - * This convenience method accepts the names for the three sequences (base - * and the two merged sequences) as explicit parameters and doesn't require - * the caller to specify a List + * Formats the results of a merge of three + * {@link org.eclipse.jgit.diff.RawText} objects in a Git conformant way, + * using diff-3 style. This convenience method accepts the names for the + * three sequences (base and the two merged sequences) as explicit + * parameters and doesn't require the caller to specify a List * * @param out * the {@link java.io.OutputStream} where to write the textual @@ -134,16 +136,17 @@ public class MergeFormatter { * @param charset * the character set used when writing conflict metadata * @throws java.io.IOException - * @since 5.2 + * if an IO error occurred + * @since 6.7 */ @SuppressWarnings("unchecked") - public void formatMerge(OutputStream out, MergeResult res, String baseName, - String oursName, String theirsName, Charset charset) - throws IOException { + public void formatMergeDiff3(OutputStream out, + MergeResult res, String baseName, String oursName, + String theirsName, Charset charset) throws IOException { List<String> names = new ArrayList<>(3); names.add(baseName); names.add(oursName); names.add(theirsName); - formatMerge(out, res, names, charset); + formatMergeDiff3(out, res, names, charset); } } |