@ -45,6 +45,7 @@ package org.eclipse.jgit.merge;
import java.io.IOException ;
import java.io.IOException ;
import java.io.OutputStream ;
import java.io.OutputStream ;
import java.nio.charset.Charset ;
import java.util.ArrayList ;
import java.util.ArrayList ;
import java.util.List ;
import java.util.List ;
@ -63,7 +64,7 @@ public class MergeFormatter {
* that are LF - separated lines .
* that are LF - separated lines .
*
*
* @param out
* @param out
* the outputstream where to write the textual presentation
* the output stream where to write the textual presentation
* @param res
* @param res
* the merge result which should be presented
* the merge result which should be presented
* @param seqName
* @param seqName
@ -72,15 +73,46 @@ public class MergeFormatter {
* " or " & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; " conflict markers . The
* " or " & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; " conflict markers . The
* names for the sequences are given in this list
* names for the sequences are given in this list
* @param charsetName
* @param charsetName
* the name of the characterS et used when writing conflict
* the name of the character s et used when writing conflict
* metadata
* metadata
* @throws java . io . IOException
* @throws java . io . IOException
* @deprecated Use
* { @link # formatMerge ( OutputStream , MergeResult , List , Charset ) }
* instead .
* /
* /
@Deprecated
public void formatMerge ( OutputStream out , MergeResult < RawText > res ,
public void formatMerge ( OutputStream out , MergeResult < RawText > res ,
List < String > seqName , String charsetName ) throws IOException {
List < String > seqName , String charsetName ) throws IOException {
new MergeFormatterPass ( out , res , seqName , charsetName ) . formatMerge ( ) ;
new MergeFormatterPass ( out , res , seqName , charsetName ) . 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 .
*
* @param out
* the output stream where to write the textual presentation
* @param res
* the merge result which should be presented
* @param seqName
* When a conflict is reported each conflicting range will get a
* name . This name is following the " & lt ; & lt ; & lt ; & lt ; & lt ; & lt ; & lt ;
* " or " & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; & gt ; " 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
* /
public void formatMerge ( OutputStream out , MergeResult < RawText > res ,
List < String > seqName , Charset charset ) throws IOException {
new MergeFormatterPass ( out , res , seqName , charset ) . formatMerge ( ) ;
}
/ * *
/ * *
* Formats the results of a merge of exactly two
* Formats the results of a merge of exactly two
* { @link org . eclipse . jgit . diff . RawText } objects in a Git conformant way .
* { @link org . eclipse . jgit . diff . RawText } objects in a Git conformant way .
@ -100,17 +132,51 @@ public class MergeFormatter {
* @param theirsName
* @param theirsName
* the name ranges from theirs should get
* the name ranges from theirs should get
* @param charsetName
* @param charsetName
* the name of the characterS et used when writing conflict
* the name of the character s et used when writing conflict
* metadata
* metadata
* @throws java . io . IOException
* @throws java . io . IOException
* @deprecated use
* { @link # formatMerge ( OutputStream , MergeResult , String , String , String , Charset ) }
* instead .
* /
* /
@SuppressWarnings ( "unchecked" )
@Deprecated
public void formatMerge ( OutputStream out , MergeResult res , String baseName ,
public void formatMerge ( OutputStream out , MergeResult res , String baseName ,
String oursName , String theirsName , String charsetName ) throws IOException {
String oursName , String theirsName , String charsetName ) throws IOException {
formatMerge ( out , res , baseName , oursName , theirsName ,
Charset . forName ( charsetName ) ) ;
}
/ * *
* 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
*
* @param out
* the { @link java . io . OutputStream } where to write the textual
* presentation
* @param res
* the merge result which should be presented
* @param baseName
* the name ranges from the base should get
* @param oursName
* the name ranges from ours should get
* @param theirsName
* the name ranges from theirs should get
* @param charset
* the character set used when writing conflict metadata
* @throws java . io . IOException
* @since 5 . 2
* /
@SuppressWarnings ( "unchecked" )
public void formatMerge ( OutputStream out , MergeResult res , String baseName ,
String oursName , String theirsName , Charset charset )
throws IOException {
List < String > names = new ArrayList < > ( 3 ) ;
List < String > names = new ArrayList < > ( 3 ) ;
names . add ( baseName ) ;
names . add ( baseName ) ;
names . add ( oursName ) ;
names . add ( oursName ) ;
names . add ( theirsName ) ;
names . add ( theirsName ) ;
formatMerge ( out , res , names , charsetName ) ;
formatMerge ( out , res , names , charset ) ;
}
}
}
}