diff options
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool')
15 files changed, 124 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandExecutor.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandExecutor.java index ebef5247e6..c64a844af1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandExecutor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandExecutor.java @@ -54,6 +54,8 @@ public class CommandExecutor { } /** + * Run command + * * @param command * the command string * @param workingDir @@ -62,8 +64,11 @@ public class CommandExecutor { * the environment * @return the execution result * @throws ToolException + * if a tool raised an error * @throws InterruptedException + * if thread was interrupted * @throws IOException + * if an IO error occurred */ public ExecutionResult run(String command, File workingDir, Map<String, String> env) @@ -101,6 +106,8 @@ public class CommandExecutor { } /** + * Check whether executable file is available + * * @param path * the executable path * @param workingDir @@ -109,8 +116,11 @@ public class CommandExecutor { * the environment * @return the execution result * @throws ToolException + * if a tool raised an error * @throws InterruptedException + * if thread was interrupted * @throws IOException + * if an IO error occurred */ public boolean checkExecutable(String path, File workingDir, Map<String, String> env) @@ -155,6 +165,9 @@ public class CommandExecutor { if (fs instanceof FS_POSIX) { commandArray = new String[1]; commandArray[0] = commandFile.getCanonicalPath(); + } else if (fs instanceof FS_Win32_Cygwin) { + commandArray = new String[1]; + commandArray[0] = commandFile.getCanonicalPath().replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ } else if (fs instanceof FS_Win32) { if (useMsys2) { commandArray = new String[3]; @@ -166,9 +179,6 @@ public class CommandExecutor { commandArray = new String[1]; commandArray[0] = commandFile.getCanonicalPath(); } - } else if (fs instanceof FS_Win32_Cygwin) { - commandArray = new String[1]; - commandArray[0] = commandFile.getCanonicalPath().replace("\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$ } else { throw new ToolException( "JGit: file system not supported: " + fs.toString()); //$NON-NLS-1$ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineDiffTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineDiffTool.java index 00dec32718..1e09796d23 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineDiffTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineDiffTool.java @@ -205,6 +205,8 @@ public enum CommandLineDiffTool { private final String parameters; /** + * Get path + * * @return path */ public String getPath() { @@ -212,6 +214,8 @@ public enum CommandLineDiffTool { } /** + * Get parameters + * * @return parameters as one string */ public String getParameters() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineMergeTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineMergeTool.java index 3a22124328..d8287f45d1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineMergeTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/CommandLineMergeTool.java @@ -273,11 +273,6 @@ public enum CommandLineMergeTool { this.exitCodeTrustable = exitCodeTrustable; } - CommandLineMergeTool(CommandLineMergeTool from) { - this(from.getPath(), from.getParameters(true), - from.getParameters(false), from.isExitCodeTrustable()); - } - CommandLineMergeTool(String path, CommandLineMergeTool from) { this(path, from.getParameters(true), from.getParameters(false), from.isExitCodeTrustable()); @@ -292,6 +287,8 @@ public enum CommandLineMergeTool { private final boolean exitCodeTrustable; /** + * Get path + * * @return path */ public String getPath() { @@ -299,6 +296,8 @@ public enum CommandLineMergeTool { } /** + * Get parameters + * * @param withBase * return parameters with base present? * @return parameters with or without base present @@ -311,6 +310,8 @@ public enum CommandLineMergeTool { } /** + * Whether exit code can be trusted + * * @return parameters */ public boolean isExitCodeTrustable() { @@ -318,6 +319,8 @@ public enum CommandLineMergeTool { } /** + * Whether command with with base present is valid + * * @return true if command with base present is valid, false otherwise */ public boolean canMergeWithoutBasePresent() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffToolConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffToolConfig.java index c8b04f90f2..e74337a8a1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffToolConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffToolConfig.java @@ -75,6 +75,8 @@ public class DiffToolConfig { } /** + * Get default tool name + * * @return the default diff tool name (diff.tool) */ public String getDefaultToolName() { @@ -82,6 +84,8 @@ public class DiffToolConfig { } /** + * Get default GUI tool name + * * @return the default GUI diff tool name (diff.guitool) */ public String getDefaultGuiToolName() { @@ -89,6 +93,8 @@ public class DiffToolConfig { } /** + * Get difftool.prompt option + * * @return the diff tool "prompt" option (difftool.prompt) */ public boolean isPrompt() { @@ -96,6 +102,8 @@ public class DiffToolConfig { } /** + * Get difftool.trustExitCode option + * * @return the diff tool "trust exit code" option (difftool.trustExitCode) */ public boolean isTrustExitCode() { @@ -103,6 +111,8 @@ public class DiffToolConfig { } /** + * Get tools map + * * @return the tools map */ public Map<String, ExternalDiffTool> getTools() { @@ -110,6 +120,8 @@ public class DiffToolConfig { } /** + * Get tool names + * * @return the tool names */ public Set<String> getToolNames() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffTools.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffTools.java index d0034df3bc..6a67bf3a1a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffTools.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/DiffTools.java @@ -172,6 +172,7 @@ public class DiffTools { * the "trust exit code" option * @return the execution result from tool * @throws ToolException + * when the tool fails */ public ExecutionResult compare(FileElement localFile, FileElement remoteFile, ExternalDiffTool tool, @@ -244,6 +245,7 @@ public class DiffTools { * path to the node in repository to parse git attributes for * @return name of the difftool if set * @throws ToolException + * when the tool failed */ public Optional<String> getExternalToolFromAttributes(final String path) throws ToolException { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalDiffTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalDiffTool.java index e01b892a53..e02697b772 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalDiffTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalDiffTool.java @@ -16,21 +16,29 @@ package org.eclipse.jgit.internal.diffmergetool; public interface ExternalDiffTool { /** + * Get tool name + * * @return the tool name */ String getName(); /** + * Get tool path + * * @return the tool path */ String getPath(); /** + * Get tool command + * * @return the tool command */ String getCommand(); /** + * Whether tool is available + * * @return availability of the tool: true if tool can be executed and false * if not */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalMergeTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalMergeTool.java index 0c3ddf9afe..022cd27f44 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalMergeTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalMergeTool.java @@ -18,11 +18,15 @@ import org.eclipse.jgit.lib.internal.BooleanTriState; public interface ExternalMergeTool extends ExternalDiffTool { /** + * Get the tool "trust exit code" option + * * @return the tool "trust exit code" option */ BooleanTriState getTrustExitCode(); /** + * Get tool command + * * @param withBase * get command with base present (true) or without base present * (false) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalToolUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalToolUtils.java index b2dd846d70..e5947102eb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalToolUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ExternalToolUtils.java @@ -57,6 +57,7 @@ public class ExternalToolUtils { * the base file (can be null) * @return the prepared (with replaced variables) command string * @throws IOException + * if an IO error occurred */ public static String prepareCommand(String command, FileElement localFile, FileElement remoteFile, FileElement mergedFile, @@ -91,6 +92,7 @@ public class ExternalToolUtils { * the base file (can be null) * @return the environment map with variables and values (file paths) * @throws IOException + * if an IO error occurred */ public static Map<String, String> prepareEnvironment(File gitDir, FileElement localFile, FileElement remoteFile, @@ -115,6 +117,8 @@ public class ExternalToolUtils { } /** + * Quote path + * * @param path * the path to be quoted * @return quoted path if it contains spaces @@ -136,6 +140,8 @@ public class ExternalToolUtils { } /** + * Whether tool is available + * * @param fs * the file system abstraction * @param gitDir @@ -160,6 +166,8 @@ public class ExternalToolUtils { } /** + * Create sorted tool set + * * @param defaultName * the default tool name * @param userDefinedNames @@ -209,6 +217,7 @@ public class ExternalToolUtils { * config key name for the tool * @return attribute value for the given tool key if set * @throws ToolException + * if the tool failed */ public static Optional<String> getExternalToolFromAttributes( final Repository repository, final String path, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/FileElement.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/FileElement.java index ba8ca54c58..37eb2d9f7d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/FileElement.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/FileElement.java @@ -28,7 +28,6 @@ public class FileElement { /** * The file element type. - * */ public enum Type { /** @@ -91,6 +90,8 @@ public class FileElement { } /** + * Create file element + * * @param path * the file path * @param type @@ -111,6 +112,8 @@ public class FileElement { } /** + * Get path + * * @return the file path */ public String getPath() { @@ -118,6 +121,8 @@ public class FileElement { } /** + * Get type + * * @return the element type */ public Type getType() { @@ -125,6 +130,8 @@ public class FileElement { } /** + * Get file + * <p> * Return * <ul> * <li>a temporary file if already created and stream is not valid</li> @@ -138,6 +145,7 @@ public class FileElement { * * @return the object stream * @throws IOException + * if an IO error occurred */ public File getFile() throws IOException { // if we have already temp file and no stream @@ -179,6 +187,7 @@ public class FileElement { * temporary directory is used * @return temporary file in directory or in the system temporary directory * @throws IOException + * if an IO error occurred */ public File createTempFile(File directory) throws IOException { if (tempFile == null) { @@ -204,6 +213,7 @@ public class FileElement { * the input string * @return the replaced input string * @throws IOException + * if an IO error occurred */ public String replaceVariable(String input) throws IOException { return input.replace("$" + type.name(), getFile().getPath()); //$NON-NLS-1$ @@ -215,6 +225,7 @@ public class FileElement { * @param env * the environment where this element should be added * @throws IOException + * if an IO error occurred */ public void addToEnv(Map<String, String> env) throws IOException { env.put(type.name(), getFile().getPath()); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeToolConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeToolConfig.java index 9625d5f101..40cb820602 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeToolConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeToolConfig.java @@ -89,6 +89,8 @@ public class MergeToolConfig { } /** + * Get default tool name + * * @return the default merge tool name (merge.tool) */ public String getDefaultToolName() { @@ -96,6 +98,8 @@ public class MergeToolConfig { } /** + * Get default GUI tool name + * * @return the default GUI merge tool name (merge.guitool) */ public String getDefaultGuiToolName() { @@ -103,6 +107,8 @@ public class MergeToolConfig { } /** + * Get mergetool.prompt option + * * @return the merge tool "prompt" option (mergetool.prompt) */ public boolean isPrompt() { @@ -110,6 +116,8 @@ public class MergeToolConfig { } /** + * Get tool "keep backup" option + * * @return the tool "keep backup" option */ public boolean isKeepBackup() { @@ -117,6 +125,8 @@ public class MergeToolConfig { } /** + * Get tool "keep temporaries" option + * * @return the tool "keepTemporaries" option */ public boolean isKeepTemporaries() { @@ -124,6 +134,8 @@ public class MergeToolConfig { } /** + * Get the tool "write to temp" option + * * @return the tool "write to temp" option */ public boolean isWriteToTemp() { @@ -131,6 +143,8 @@ public class MergeToolConfig { } /** + * Get the tools map + * * @return the tools map */ public Map<String, ExternalMergeTool> getTools() { @@ -138,6 +152,8 @@ public class MergeToolConfig { } /** + * Get tool names + * * @return the tool names */ public Set<String> getToolNames() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeTools.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeTools.java index b903201264..213ce6871e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeTools.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/MergeTools.java @@ -26,14 +26,13 @@ import java.util.Set; import java.util.TreeMap; import org.eclipse.jgit.internal.JGitText; -import org.eclipse.jgit.internal.diffmergetool.FileElement.Type; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.lib.internal.BooleanTriState; import org.eclipse.jgit.treewalk.TreeWalk; import org.eclipse.jgit.util.FS; -import org.eclipse.jgit.util.StringUtils; import org.eclipse.jgit.util.FS.ExecutionResult; +import org.eclipse.jgit.util.StringUtils; /** * Manages merge tools. @@ -184,6 +183,7 @@ public class MergeTools { * the selected tool * @return the execution result from tool * @throws ToolException + * if the tool failed */ public ExecutionResult merge(FileElement localFile, FileElement remoteFile, FileElement mergedFile, FileElement baseFile, File tempDir, @@ -241,7 +241,7 @@ public class MergeTools { FileElement backup = null; Path path = Paths.get(from.getPath()); if (Files.exists(path)) { - backup = new FileElement(from.getPath(), Type.BACKUP); + backup = new FileElement(from.getPath(), FileElement.Type.BACKUP); Files.copy(path, backup.createTempFile(toParentDir).toPath(), StandardCopyOption.REPLACE_EXISTING); } @@ -254,6 +254,7 @@ public class MergeTools { * @return the created temporary directory if (mergetol.writeToTemp == true) * or null if not configured or false. * @throws IOException + * if an IO error occurred */ public File createTempDirectory() throws IOException { return config.isWriteToTemp() @@ -271,6 +272,8 @@ public class MergeTools { } /** + * Get predefined tool names + * * @return the predefined tool names */ public Set<String> getPredefinedToolNames() { @@ -305,6 +308,7 @@ public class MergeTools { * path to the node in repository to parse git attributes for * @return name of the difftool if set * @throws ToolException + * if the tool failed */ public Optional<String> getExternalToolFromAttributes(final String path) throws ToolException { @@ -329,6 +333,8 @@ public class MergeTools { } /** + * Get user defined tools + * * @return the user defined tools */ public Map<String, ExternalMergeTool> getUserDefinedTools() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/PreDefinedDiffTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/PreDefinedDiffTool.java index e1169a2d60..c1d69b4f11 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/PreDefinedDiffTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/PreDefinedDiffTool.java @@ -43,6 +43,7 @@ public class PreDefinedDiffTool extends UserDefinedDiffTool { /** * @param path + * path string */ @Override public void setPath(String path) { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ToolException.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ToolException.java index 73d3588906..cd11325433 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ToolException.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/ToolException.java @@ -34,13 +34,15 @@ public class ToolException extends Exception { private static final long serialVersionUID = 1L; /** - * + * Create tool exception */ public ToolException() { this(null, null, false); } /** + * Create tool exception + * * @param message * the exception message */ @@ -49,6 +51,8 @@ public class ToolException extends Exception { } /** + * Create tool exception + * * @param message * the exception message * @param result @@ -64,6 +68,8 @@ public class ToolException extends Exception { } /** + * Create tool exception + * * @param message * the exception message * @param cause @@ -76,6 +82,8 @@ public class ToolException extends Exception { } /** + * Create tool exception + * * @param cause * the cause for throw */ @@ -86,6 +94,8 @@ public class ToolException extends Exception { } /** + * Whether result is valid + * * @return true if result is valid, false else */ public boolean isResult() { @@ -93,6 +103,8 @@ public class ToolException extends Exception { } /** + * Get execution result + * * @return the execution result */ public ExecutionResult getResult() { @@ -100,6 +112,8 @@ public class ToolException extends Exception { } /** + * Whether execution failed with an error + * * @return true if command execution error appears, false otherwise */ public boolean isCommandExecutionError() { @@ -107,6 +121,8 @@ public class ToolException extends Exception { } /** + * Get buffered stderr as a String + * * @return the result Stderr */ public String getResultStderr() { @@ -123,6 +139,8 @@ public class ToolException extends Exception { } /** + * Get buffered stdout as a String + * * @return the result Stdout */ public String getResultStdout() { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedDiffTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedDiffTool.java index eb72d01cdb..62bde28feb 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedDiffTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedDiffTool.java @@ -110,6 +110,8 @@ public class UserDefinedDiffTool implements ExternalDiffTool { } /** + * Set whether tool is available + * * @param available * true if tool can be found and false if not */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedMergeTool.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedMergeTool.java index 1dd2f0d793..b1a5a22ef5 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedMergeTool.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/diffmergetool/UserDefinedMergeTool.java @@ -49,6 +49,8 @@ public class UserDefinedMergeTool extends UserDefinedDiffTool } /** + * Set "trust exit code" flag + * * @param trustExitCode * the new "trust exit code" flag */ @@ -57,9 +59,11 @@ public class UserDefinedMergeTool extends UserDefinedDiffTool } /** + * Get command + * * @param withBase * not used, because user-defined merge tool can only define one - * cmd -> it must handle with and without base present (empty) + * cmd -> it must handle with and without base present (empty) * @return the tool command */ @Override |