|
Lines 225-266
Link Here
|
| 225 |
*/ |
225 |
*/ |
| 226 |
private String asReference(String repoLocation, String module, String projectName, String tagName) { |
226 |
private String asReference(String repoLocation, String module, String projectName, String tagName) { |
| 227 |
// parse protocol, host, repository root from repoLocation |
227 |
// parse protocol, host, repository root from repoLocation |
| 228 |
String sep = repoLocation.substring(0, 1); |
228 |
String protocol = null; |
| 229 |
String[] split = repoLocation.substring(1).split(sep); |
229 |
String host = null; |
| 230 |
if (split.length == 3) { |
230 |
String root = null; |
| 231 |
String protocol = split[0]; |
231 |
|
| 232 |
String host = split[1]; |
232 |
int at = repoLocation.indexOf('@'); |
| 233 |
int index = host.indexOf('@'); |
233 |
if (at < 0) { |
| 234 |
if (index >= 0 && index < host.length() - 2) { |
234 |
// should be a local protocol |
| 235 |
host = host.substring(index + 1); |
235 |
if (repoLocation.startsWith(":local:")) { //$NON-NLS-1$ |
|
|
236 |
protocol = "local"; //$NON-NLS-1$ |
| 237 |
root = repoLocation.substring(7); |
| 236 |
} |
238 |
} |
| 237 |
String root = split[2]; |
239 |
} else if (at < (repoLocation.length() - 2)) { |
| 238 |
StringBuffer buffer = new StringBuffer(); |
240 |
String serverRoot = repoLocation.substring(at + 1); |
| 239 |
buffer.append("scm:cvs"); //$NON-NLS-1$ |
241 |
String protocolUserPass = repoLocation.substring(0, at); |
| 240 |
buffer.append(sep); |
242 |
int colon = serverRoot.indexOf(':'); |
| 241 |
buffer.append(protocol); |
243 |
if (colon > 0) { |
| 242 |
buffer.append(sep); |
244 |
host = serverRoot.substring(0, colon); |
| 243 |
buffer.append(host); |
245 |
if (colon < (serverRoot.length() - 2)) { |
| 244 |
buffer.append(sep); |
246 |
root = serverRoot.substring(colon + 1); |
| 245 |
buffer.append(root); |
247 |
} |
|
|
248 |
if (protocolUserPass.startsWith(":")) { //$NON-NLS-1$ |
| 249 |
colon = protocolUserPass.indexOf(':', 1); |
| 250 |
if (colon > 0) { |
| 251 |
protocol = protocolUserPass.substring(1, colon); |
| 252 |
} |
| 253 |
} else { |
| 254 |
// missing protocol, assume p-server |
| 255 |
protocol = "pserver"; //$NON-NLS-1$ |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 246 |
|
259 |
|
| 247 |
buffer.append(sep); |
260 |
if (protocol == null || root == null) { |
| 248 |
buffer.append(module); |
261 |
return null; // invalid syntax |
|
|
262 |
} |
| 249 |
|
263 |
|
| 250 |
Path modulePath = new Path(module); |
264 |
// use '|' as separator if the root location uses a colon for a Windows path |
| 251 |
if (!modulePath.lastSegment().equals(projectName)) { |
265 |
String sep = ":"; //$NON-NLS-1$ |
| 252 |
buffer.append(";project=\""); //$NON-NLS-1$ |
266 |
if (root.indexOf(':') >= 0) { |
| 253 |
buffer.append(projectName); |
267 |
sep = "|"; //$NON-NLS-1$ |
| 254 |
buffer.append('"'); |
268 |
} |
| 255 |
} |
269 |
StringBuffer buffer = new StringBuffer(); |
|
|
270 |
buffer.append("scm:cvs"); //$NON-NLS-1$ |
| 271 |
buffer.append(sep); |
| 272 |
buffer.append(protocol); |
| 273 |
buffer.append(sep); |
| 274 |
if (host != null) { |
| 275 |
buffer.append(host); |
| 276 |
buffer.append(sep); |
| 277 |
} |
| 278 |
buffer.append(root); |
| 279 |
buffer.append(sep); |
| 280 |
buffer.append(module); |
| 281 |
|
| 282 |
Path modulePath = new Path(module); |
| 283 |
if (!modulePath.lastSegment().equals(projectName)) { |
| 284 |
buffer.append(";project=\""); //$NON-NLS-1$ |
| 285 |
buffer.append(projectName); |
| 286 |
buffer.append('"'); |
| 287 |
} |
| 256 |
|
288 |
|
| 257 |
if (tagName != null && !tagName.equals("HEAD")) { //$NON-NLS-1$ |
289 |
if (tagName != null && !tagName.equals("HEAD")) { //$NON-NLS-1$ |
| 258 |
buffer.append(";tag="); //$NON-NLS-1$ |
290 |
buffer.append(";tag="); //$NON-NLS-1$ |
| 259 |
buffer.append(tagName); |
291 |
buffer.append(tagName); |
| 260 |
} |
|
|
| 261 |
return buffer.toString(); |
| 262 |
} |
292 |
} |
| 263 |
return null; |
293 |
return buffer.toString(); |
| 264 |
} |
294 |
} |
| 265 |
|
295 |
|
| 266 |
/** |
296 |
/** |