java.lang.Object
org.eclipse.jgit.internal.diffmergetool.MergeTools
Manages merge tools.
-
Constructor Summary
ConstructorsConstructorDescriptionMergeTools
(Repository repo) Creates the external merge-tools manager for given repository.MergeTools
(StoredConfig config) Creates the external diff-tools manager for given configuration. -
Method Summary
Modifier and TypeMethodDescriptionCreate temporary directory.Get all tool names.getDefaultToolName
(boolean gui) Get the default (gui-)tool name.ProvidesOptional
with the name of an external merge tool if specified in git configuration for a path.Get first available tool name.Checks the availability of the predefined tools in the system.Get predefined tool namesgetPredefinedTools
(boolean checkAvailability) Get predefined tools map.Get user defined tool names.Get user defined toolsboolean
Is interactive merge (prompt enabled) ?merge
(FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile, File tempDir, Optional<String> toolName, BooleanTriState prompt, boolean gui, PromptContinueHandler promptHandler, InformNoToolHandler noToolHandler) Merge two versions of a file with optional base file.merge
(FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile, File tempDir, ExternalMergeTool tool) Merge two versions of a file with optional base file.
-
Constructor Details
-
MergeTools
Creates the external merge-tools manager for given repository.- Parameters:
repo
- the repository
-
MergeTools
Creates the external diff-tools manager for given configuration.- Parameters:
config
- the git configuration
-
-
Method Details
-
merge
public Optional<FS.ExecutionResult> merge(FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile, File tempDir, Optional<String> toolName, BooleanTriState prompt, boolean gui, PromptContinueHandler promptHandler, InformNoToolHandler noToolHandler) throws ToolException Merge two versions of a file with optional base file.- Parameters:
localFile
- The local/left version of the file.remoteFile
- The remote/right version of the file.mergedFile
- The file for the result.baseFile
- The base version of the file. May be null.tempDir
- The tmepDir used for the files. May be null.toolName
- Optionally the name of the tool to use. If not given the default tool will be used.prompt
- Optionally a flag whether to prompt the user before compare. If not given the default will be used.gui
- A flag whether to prefer a gui tool.promptHandler
- The handler to use when needing to prompt the user if he wants to continue.noToolHandler
- The handler to use when needing to inform the user, that no tool is configured.- Returns:
- the optional result of executing the tool if it was executed
- Throws:
ToolException
- when the tool fails
-
merge
public FS.ExecutionResult merge(FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile, File tempDir, ExternalMergeTool tool) throws ToolException Merge two versions of a file with optional base file.- Parameters:
localFile
- the local file elementremoteFile
- the remote file elementmergedFile
- the merged file elementbaseFile
- the base file element (can be null)tempDir
- the temporary directory (needed for backup and auto-remove, can be null)tool
- the selected tool- Returns:
- the execution result from tool
- Throws:
ToolException
- if the tool failed
-
createTempDirectory
Create temporary directory.- Returns:
- the created temporary directory if (mergetol.writeToTemp == true) or null if not configured or false.
- Throws:
IOException
- if an IO error occurred
-
getUserDefinedToolNames
Get user defined tool names.- Returns:
- the user defined tool names
-
getPredefinedToolNames
Get predefined tool names- Returns:
- the predefined tool names
-
getAllToolNames
Get all tool names.- Returns:
- the all tool names (default or available tool name is the first in the set)
-
getExternalToolFromAttributes
ProvidesOptional
with the name of an external merge tool if specified in git configuration for a path. The formed git configuration results from global rules as well as merged rules from info and worktree attributes. TriggersTreeWalk
until specified path found in the tree.- Parameters:
path
- path to the node in repository to parse git attributes for- Returns:
- name of the difftool if set
- Throws:
ToolException
- if the tool failed
-
getPredefinedAvailableTools
Checks the availability of the predefined tools in the system.- Returns:
- set of predefined available tools
-
getUserDefinedTools
Get user defined tools- Returns:
- the user defined tools
-
getPredefinedTools
Get predefined tools map.- Parameters:
checkAvailability
- true: for checking if tools can be executed; ATTENTION: this check took some time, do not execute often (store the map for other actions); false: availability is NOT checked: isAvailable() returns default false is this case!- Returns:
- the predefined tools with optionally checked availability (long running operation)
-
getFirstAvailableTool
Get first available tool name.- Returns:
- the name of first available predefined tool or null
-
isInteractive
public boolean isInteractive()Is interactive merge (prompt enabled) ?- Returns:
- is interactive (config prompt enabled) ?
-
getDefaultToolName
Get the default (gui-)tool name.- Parameters:
gui
- use the diff.guitool setting ?- Returns:
- the default tool name
-