use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class SVNRepositories method readState.
/**
* read the state of the plugin, ie the repositories locations
*
* @param dis
* @throws IOException
* @throws SVNException
*/
private void readState(DataInputStream dis) throws IOException, SVNException {
int version = dis.readInt();
if ((version < REPOSITORIES_STATE_FILE_VERSION_1) || (version > REPOSITORIES_STATE_FILE_VERSION_3)) {
Util.logError(Policy.bind("SVNProviderPlugin.unknownStateFileVersion", new Integer(version).toString()), // $NON-NLS-1$
null);
return;
}
int count = dis.readInt();
for (int i = 0; i < count; i++) {
ISVNRepositoryLocation root = SVNRepositoryLocation.fromString(dis.readUTF());
addToRepositoriesCache(root);
if (version >= REPOSITORIES_STATE_FILE_VERSION_2) {
String label = dis.readUTF();
if (!label.equals("")) {
root.setLabel(label);
}
}
if (version >= REPOSITORIES_STATE_FILE_VERSION_3) {
String repositoryRoot = dis.readUTF();
if (!repositoryRoot.equals("")) {
root.setRepositoryRoot(new SVNUrl(repositoryRoot));
}
}
}
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class SVNRepositories method writeState.
/**
* write the state of the plugin ie the repositories locations
*
* @param dos
* @throws IOException
*/
private void writeState(DataOutputStream dos) throws IOException {
// Write the repositories
dos.writeInt(REPOSITORIES_STATE_FILE_VERSION_3);
// Write out the repos
Collection<ISVNRepositoryLocation> repos = repositories.values();
dos.writeInt(repos.size());
for (ISVNRepositoryLocation reposLocation : repos) {
SVNRepositoryLocation root = (SVNRepositoryLocation) reposLocation;
dos.writeUTF(root.getLocation());
if (root.getLabel() == null) {
dos.writeUTF("");
} else {
dos.writeUTF(root.getLabel());
}
if (root.getRepositoryRoot() == null) {
dos.writeUTF("");
} else {
dos.writeUTF(root.getRepositoryRoot().toString());
}
}
dos.flush();
dos.close();
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class SVNRepositories method getRepository.
/**
* Get the repository instance which matches the given String. The format of the String is an url
*/
public ISVNRepositoryLocation getRepository(String location, boolean useRootUrl) throws SVNException {
Set<String> keys = repositories.keySet();
for (String url : keys) {
if (url.equals(location) || location.indexOf(url + "/") != -1) {
return (ISVNRepositoryLocation) repositories.get(url);
}
}
// If we haven't found a matching repository yet, check to see if the default
// port is redundantly specified in the location. If it is, check the known
// repositories again to see if there is a match for the location with the
// default port stripped out (normalizedLocation).
String normalizedLocation = getNormalizedLocation(location);
if (!normalizedLocation.equals(location)) {
for (String url : keys) {
if (url.equals(normalizedLocation) || normalizedLocation.indexOf(url + "/") != -1) {
return (ISVNRepositoryLocation) repositories.get(url);
}
}
}
// else we couldn't find it, fall through to adding new repo.
ISVNRepositoryLocation repository = SVNRepositoryLocation.fromString(location, false, useRootUrl);
addToRepositoriesCache(repository);
return repository;
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class AliasManager method transformUrl.
public static String transformUrl(IResource resource, Alias alias) {
String aliasUrl = alias.getUrl();
String a;
ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
ISVNRepositoryLocation repository = svnResource.getRepository();
if (svnResource.getUrl().toString().length() <= aliasUrl.length())
a = "";
else
a = svnResource.getUrl().toString().substring(aliasUrl.length());
String b = repository.getUrl().toString();
String c;
if (alias.getRelativePath() == null)
c = "";
else
c = alias.getRelativePath();
return b + c + a;
}
use of org.tigris.subversion.subclipse.core.ISVNRepositoryLocation in project subclipse by subclipse.
the class ShowDifferencesAsUnifiedDiffDialogWC method okPressed.
protected void okPressed() {
success = true;
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
ISVNRepositoryLocation repository = null;
ISVNClientAdapter svnClient = null;
try {
if (toHeadButton.getSelection())
toRevision = SVNRevision.HEAD;
else {
int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
long toRevisionLong = toRevisionInt;
toRevision = new SVNRevision.Number(toRevisionLong);
}
toUrl = new SVNUrl(toUrlText.getText().trim());
File path = new File(resource.getLocation().toString());
svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
pegRevision = null;
if (toUrlText.getText().equals(selectedResourceUrl)) {
ISVNRemoteResource baseResource = svnResource.getBaseResource();
if (baseResource != null) {
pegRevision = baseResource.getLastChangedRevision();
}
}
if (pegRevision == null) {
pegRevision = toRevision;
}
repository = svnResource.getRepository();
svnClient = repository.getSVNClient();
ISVNInfo svnInfo = svnClient.getInfo(toUrl, toRevision, pegRevision);
SVNNodeKind nodeKind = svnInfo.getNodeKind();
if (resource instanceof IContainer) {
if (nodeKind.toInt() == SVNNodeKind.FILE.toInt()) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
success = false;
return;
}
} else {
if (nodeKind.toInt() == SVNNodeKind.DIR.toInt()) {
MessageDialog.openError(getShell(), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.branchTag"), Policy.bind("ShowDifferencesAsUnifiedDiffDialog.fileToFolder"));
success = false;
return;
}
}
if (diffButton.getSelection()) {
diffToOutputFile = true;
file = new File(fileText.getText().trim());
if (file.exists()) {
if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
return;
}
operation = new ShowDifferencesAsUnifiedDiffOperationWC(targetPart, path, toUrl, toRevision, file);
operation.setGraphicalCompare(true);
} else {
diffToOutputFile = false;
success = true;
}
} catch (Exception e) {
MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
success = false;
} finally {
if (repository != null) {
repository.returnSVNClient(svnClient);
}
}
}
});
if (!success)
return;
toUrlText.saveUrl();
super.okPressed();
}
Aggregations