1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
package net.sf.statsvn.output; |
24 | |
|
25 | |
import java.io.File; |
26 | |
|
27 | |
import net.sf.statcvs.output.ConfigurationException; |
28 | |
import net.sf.statcvs.output.ConfigurationOptions; |
29 | |
import net.sf.statcvs.util.FileUtils; |
30 | |
import net.sf.statsvn.util.ISvnProcessor; |
31 | |
import net.sf.statsvn.util.JavaUtilTaskLogger; |
32 | |
import net.sf.statsvn.util.SvnCommandLineProcessor; |
33 | |
import net.sf.statsvn.util.TaskLogger; |
34 | |
import net.sf.statsvn.util.svnkit.SvnKitProcessor; |
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public final class SvnConfigurationOptions { |
47 | |
private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000; |
48 | 124 | |
49 | |
private static final int DEFAULT_NUMBER_THREADS = 25; |
50 | 124 | |
51 | 4 | private static String cacheDir = ""; |
52 | 124 | |
53 | 4 | private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator(); |
54 | 124 | |
55 | 4 | private static String svnUsername = null; |
56 | 124 | |
57 | 4 | private static String svnPassword = null; |
58 | 124 | |
59 | 4 | private static TaskLogger taskLogger = new JavaUtilTaskLogger(); |
60 | 124 | |
61 | 4 | private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS; |
62 | 124 | |
63 | 4 | private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY; |
64 | 124 | |
65 | 4 | private static boolean dump = false; |
66 | 124 | |
67 | 4 | private static boolean anonymize = false; |
68 | |
|
69 | 128 | private static String tagsDirectory = "/tags/"; |
70 | |
|
71 | |
|
72 | 4 | private static boolean useLegacyDiff = false; |
73 | |
|
74 | |
private static ISvnProcessor processor; |
75 | 0 | |
76 | 4 | private static boolean useSvnKit = false; |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | 0 | private SvnConfigurationOptions() { |
83 | 0 | } |
84 | 58 | |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public static String getCacheDir() { |
91 | 2 | return cacheDir; |
92 | |
} |
93 | |
|
94 | |
|
95 | |
|
96 | 29 | |
97 | 29 | |
98 | |
|
99 | 29 | |
100 | 29 | |
101 | 0 | |
102 | |
public static void setCacheDir(String cacheDir) throws ConfigurationException { |
103 | 30 | if (!cacheDir.endsWith(FileUtils.getDirSeparator())) { |
104 | 30 | cacheDir += FileUtils.getDefaultDirSeparator(); |
105 | |
} |
106 | 1 | final File cDir = new File(cacheDir); |
107 | 1 | if (!cDir.exists() && !cDir.mkdirs()) { |
108 | 0 | throw new ConfigurationException("Can't create cache directory: " + cacheDir); |
109 | |
} |
110 | 1 | SvnConfigurationOptions.cacheDir = cacheDir; |
111 | 1 | } |
112 | |
|
113 | 0 | |
114 | 0 | |
115 | |
|
116 | |
|
117 | 0 | |
118 | |
|
119 | |
public static void setCacheDirToDefault() throws ConfigurationException { |
120 | 0 | setCacheDir(DEFAULT_CACHE_DIR); |
121 | 0 | } |
122 | |
|
123 | |
public static File getCheckedOutDirectoryAsFile() { |
124 | 0 | return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator()); |
125 | |
} |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public static String getSvnPassword() { |
131 | 0 | return svnPassword; |
132 | 0 | } |
133 | 0 | |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public static void setSvnPassword(final String svnPassword) { |
139 | 0 | SvnConfigurationOptions.svnPassword = svnPassword; |
140 | 0 | } |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public static String getSvnUsername() { |
146 | 0 | return svnUsername; |
147 | 0 | } |
148 | 0 | |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
public static void setSvnUsername(final String svnUsername) { |
154 | 227517 | SvnConfigurationOptions.svnUsername = svnUsername; |
155 | 0 | } |
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
public static TaskLogger getTaskLogger() { |
161 | 7836 | return taskLogger; |
162 | 0 | } |
163 | 0 | |
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
public static void setTaskLogger(final TaskLogger taskLogger) { |
169 | 116 | SvnConfigurationOptions.taskLogger = taskLogger; |
170 | 0 | } |
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
public static int getNumberSvnDiffThreads() { |
176 | 4 | return numberSvnDiffThreads; |
177 | 0 | } |
178 | 0 | |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
public static void setNumberSvnDiffThreads(final int numberSvnDiffThreads) { |
184 | 0 | SvnConfigurationOptions.numberSvnDiffThreads = numberSvnDiffThreads; |
185 | 0 | } |
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
public static long getThresholdInMsToUseConcurrency() { |
191 | 0 | return thresholdInMsToUseConcurrency; |
192 | 0 | } |
193 | 0 | |
194 | |
|
195 | |
|
196 | 0 | |
197 | 0 | |
198 | |
public static void setThresholdInMsToUseConcurrency(final long thresholdToUseConcurrency) { |
199 | 0 | SvnConfigurationOptions.thresholdInMsToUseConcurrency = thresholdToUseConcurrency; |
200 | 29 | } |
201 | |
|
202 | |
public static void setDumpContent(final boolean dumpContent) { |
203 | 0 | dump = dumpContent; |
204 | 0 | } |
205 | 0 | |
206 | |
public static boolean isDumpContent() { |
207 | 1 | return dump; |
208 | 161074 | } |
209 | |
|
210 | |
public static void setAnonymize(final boolean bAnon) { |
211 | 0 | anonymize = bAnon; |
212 | 0 | } |
213 | |
|
214 | |
public static boolean isAnonymize() { |
215 | 5551 | return anonymize; |
216 | 0 | } |
217 | 0 | |
218 | 0 | |
219 | |
|
220 | |
|
221 | 0 | public static void setTagsDirectory(final String tagsDir) { |
222 | 0 | if (tagsDir != null) { |
223 | 0 | tagsDirectory = tagsDir.replace('\\', '/'); |
224 | 0 | if (!tagsDirectory.endsWith("/")) { |
225 | 0 | tagsDirectory = tagsDir + "/"; |
226 | |
} |
227 | 157122 | } |
228 | 0 | } |
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
public static String getTagsDirectory() { |
234 | 5418 | return tagsDirectory; |
235 | |
} |
236 | 58 | |
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | |
public static boolean isLegacyDiff() { |
243 | 2 | return useLegacyDiff; |
244 | |
} |
245 | 0 | |
246 | 0 | |
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
public static void setLegacyDiff(final boolean isLegacy) { |
252 | 0 | useLegacyDiff = isLegacy; |
253 | 0 | } |
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
public static boolean isUsingSVNKit() { |
261 | 0 | return useSvnKit; |
262 | |
} |
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
public static void setUsingSvnKit(final boolean isSvnKit) { |
270 | 0 | useSvnKit = isSvnKit; |
271 | 0 | } |
272 | |
|
273 | |
public static ISvnProcessor getProcessor() |
274 | |
{ |
275 | 0 | if (processor==null) { |
276 | 0 | if (isUsingSVNKit()) { |
277 | |
try { |
278 | 0 | processor = new SvnKitProcessor(); |
279 | 0 | } catch (NoClassDefFoundError ex) |
280 | |
{ |
281 | 0 | getTaskLogger().error("Unable to find svnkit.jar and/or jna.jar in the same folder as statsvn.jar. Please copy these files and try again."); |
282 | 0 | throw ex; |
283 | 0 | } |
284 | |
} |
285 | |
else |
286 | 0 | processor = new SvnCommandLineProcessor(); |
287 | |
} |
288 | 0 | return processor; |
289 | |
|
290 | |
} |
291 | |
|
292 | |
} |