be.re.repo
Interface MergeDocument


public interface MergeDocument

The interface for external modules to perform a three-way merge of a document. It will be called when a version on one branch has to be merged with a version on another. This decision is taken based on the structure of the version tree and on the outcome of the TestDifference module that applies to the document format. Such modules are declared in /configuration/maps.xml using the merge element as in the following example:

 <merge>
   <mime-type>text/*</mime-type>
   <!-- Additional mime-type elements can come here. -->
   <!-- Several path elements can come here. -->
   <class>
     <name>be.re.repo.mod.MergeText</name>
     <!-- Optional URL relative to maps.xml.
     <jar>modules/my_module.jar</jar>
   </class>
 </merge>
 
 

Author:
Werner Donné
See Also:
TestDifference

Method Summary
 void complete(InputStream in, OutputStream out, String mimeType, Context context)
          This method is called to perform completion on the contents of a version when the shouldComplete method returns true.
 boolean merge(InputStream base, InputStream source, InputStream target, OutputStream out, String mimeType, Context context)
          This method calculates the merge and detects possible conflicts.
 boolean shouldComplete(String mimeType)
           
 boolean storeWithConflicts(String mimeType)
           
 

Method Detail

complete

void complete(InputStream in,
              OutputStream out,
              String mimeType,
              Context context)
              throws IOException
This method is called to perform completion on the contents of a version when the shouldComplete method returns true. The method can take into account the conflict resolution actions the user may have done on the version.

Parameters:
in - the inputstream of the version.
out - the outputstream into which the completed version should be written.
mimeType - the MIME type of the document.
context - the repository context.
Throws:
IOException

merge

boolean merge(InputStream base,
              InputStream source,
              InputStream target,
              OutputStream out,
              String mimeType,
              Context context)
              throws IOException
This method calculates the merge and detects possible conflicts.

Parameters:
base - the inputstream of the version that is a common ancestor of source and target in the version tree.
source - the inputstream of the version on the branch that is to be merged into the other branch.
target - the inputstream of the version on the branch into which the merge is being done.
out - the outputstream into which the merged result should be written.
mimeType - the MIME type of the document.
context - the repository context.
Returns:
true if the merge is automatic, false if there are conflicts.
Throws:
IOException

shouldComplete

boolean shouldComplete(String mimeType)
Parameters:
mimeType - the MIME type of the document.
Returns:
true if the contents of the version should be subjected to a completion process. This normally involves a user who interactively resolves conflicts.

storeWithConflicts

boolean storeWithConflicts(String mimeType)
Parameters:
mimeType - the MIME type of the document.
Returns:
true if it is OK to store the result despite the presence of conflicts, false otherwise.