1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* Copyright (C) 2018-2022, Andre Bossert <andre.bossert@siemens.com>
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.diffmergetool;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.internal.BooleanTriState;
/**
* Manages merge tools.
*/
public class MergeTools {
private final MergeToolConfig config;
private final Map<String, ExternalMergeTool> predefinedTools;
private final Map<String, ExternalMergeTool> userDefinedTools;
/**
* @param repo
* the repository database
*/
public MergeTools(Repository repo) {
config = repo.getConfig().get(MergeToolConfig.KEY);
predefinedTools = setupPredefinedTools();
userDefinedTools = setupUserDefinedTools();
}
/**
* @param localFile
* the local file element
* @param remoteFile
* the remote file element
* @param baseFile
* the base file element
* @param mergedFilePath
* the path of 'merged' file
* @param toolName
* the selected tool name (can be null)
* @param prompt
* the prompt option
* @param trustExitCode
* the "trust exit code" option
* @param gui
* the GUI option
* @return the execution result from tool
* @throws ToolException
*/
public int merge(String localFile,
String remoteFile, String baseFile, String mergedFilePath,
String toolName, BooleanTriState prompt, BooleanTriState gui,
BooleanTriState trustExitCode)
throws ToolException {
return 0;
}
/**
* @return the tool names
*/
public Set<String> getToolNames() {
return config.getToolNames();
}
/**
* @return the user defined tools
*/
public Map<String, ExternalMergeTool> getUserDefinedTools() {
return userDefinedTools;
}
/**
* @return the available predefined tools
*/
public Map<String, ExternalMergeTool> getAvailableTools() {
return predefinedTools;
}
/**
* @return the NOT available predefined tools
*/
public Map<String, ExternalMergeTool> getNotAvailableTools() {
return new TreeMap<>();
}
/**
* @param gui
* use the diff.guitool setting ?
* @return the default tool name
*/
public String getDefaultToolName(BooleanTriState gui) {
return gui != BooleanTriState.UNSET ? "my_gui_tool" //$NON-NLS-1$
: "my_default_toolname"; //$NON-NLS-1$
}
/**
* @return is interactive (config prompt enabled) ?
*/
public boolean isInteractive() {
return config.isPrompt();
}
private Map<String, ExternalMergeTool> setupPredefinedTools() {
return new TreeMap<>();
}
private Map<String, ExternalMergeTool> setupUserDefinedTools() {
return new TreeMap<>();
}
}
|