com.microsoft.tfs.core.util.diffmerge
Class ExternalRunner

java.lang.Object
  extended by com.microsoft.tfs.core.util.diffmerge.ExternalRunner

public class ExternalRunner
extends java.lang.Object

Static methods to handle the creation and completion of external processes launched to compare or merge file content.

Since:
TEE-SDK-10.1
Thread-safety:
immutable

Constructor Summary
ExternalRunner()
           
 
Method Summary
static com.microsoft.tfs.util.process.ProcessRunner beginMerge(ThreeWayMerge twm, ExternalTool tool, com.microsoft.tfs.util.process.ProcessFinishedHandler finishedHandler, java.io.OutputStream capturedStandardOutput, java.io.OutputStream capturedStandardError)
          Runs an external merge tool to complete the given three way merge.
static java.lang.String[] combineCommandAndArguments(java.lang.String command, java.lang.String[] arguments)
          Combine the given command string and argument strings into one array to pass to something like Runtime.exec(String[]).
static boolean endMerge(com.microsoft.tfs.util.process.ProcessRunner mergeProcessRunner, java.lang.String mergedFileName)
          Ends an external merge that was run via ProcessRunner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExternalRunner

public ExternalRunner()
Method Detail

beginMerge

public static com.microsoft.tfs.util.process.ProcessRunner beginMerge(ThreeWayMerge twm,
                                                                      ExternalTool tool,
                                                                      com.microsoft.tfs.util.process.ProcessFinishedHandler finishedHandler,
                                                                      java.io.OutputStream capturedStandardOutput,
                                                                      java.io.OutputStream capturedStandardError)
                                                               throws ExternalToolException
Runs an external merge tool to complete the given three way merge. The tool is chosen by the extension of the three way merge's modified file name.

You probably don't want to call this method to perform merges. See ThreeWayMerge.beginExternalMerge(Conflict, ExternalTool, ProcessFinishedHandler, OutputStream, OutputStream) instead.

Parameters:
twm - the three way merge to run (must not be null)
tool - the merge tool to use (must not be null)
finishedHandler - an event handler whose methods are invoked when the process runner reaches one of its terminal states. The caller would normally implement the handler to call endMerge(ProcessRunner, String) when the runner reaches any terminal state. May be null if no state information is desired.
capturedStandardOutput - a stream to capture the text written by the child process to its standard output stream. Pass null if you don't want this output.

See the warning in ProcessRunner's Javadoc about deadlock.

capturedStandardError - a stream to capture the text written by the child process to its standard error stream. Pass null if you don't want this output.

See the warning in ProcessRunner's Javadoc about deadlock.

Returns:
the merge process runner started to complete the merge asynchronously. You can query this object for completion. null if and only if there was no merge tool configured that can handle this content.
Throws:
ExternalToolException - if the configured merge command or arguments string caused a problem creating the merge tool.

endMerge

public static boolean endMerge(com.microsoft.tfs.util.process.ProcessRunner mergeProcessRunner,
                               java.lang.String mergedFileName)
Ends an external merge that was run via ProcessRunner. If the runner is not already in a terminal state, this method ProcessRunner.waitForFinish() and blocks until it enters one.

It is safe to call into this method inside a ProcessFinishedHandler method, because the state of the runner is guaranteed to be a terminal state when these methods are invoked, and this method can proceed immediately if the runner has reached a terminal state.

Parameters:
mergeProcessRunner - the process runner returned by beginMerge(ThreeWayMerge, ExternalTool, ProcessFinishedHandler, OutputStream, OutputStream) If null, the merge is a failure and false is returned.
mergedFileName - the file name of the merge result to check for on disk. Caller does not need to ensure this file exists (this method does that). Must not be null.
Returns:
true if the merge was a success, false if it was not (and the merged file was deleted by this method).

combineCommandAndArguments

public static java.lang.String[] combineCommandAndArguments(java.lang.String command,
                                                            java.lang.String[] arguments)
Combine the given command string and argument strings into one array to pass to something like Runtime.exec(String[]).

Parameters:
command - the command (must not be null)
arguments - the arguments (must not be null)
Returns:
a new array containing first the given command then all the arguments in their original order.


© 2015 Microsoft. All rights reserved.