Search in sources :

Example 6 with ISVNRepositoryLocation

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));
            }
        }
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 7 with ISVNRepositoryLocation

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();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)

Example 8 with ISVNRepositoryLocation

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;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)

Example 9 with ISVNRepositoryLocation

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;
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

Example 10 with ISVNRepositoryLocation

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();
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) ShowDifferencesAsUnifiedDiffOperationWC(org.tigris.subversion.subclipse.ui.operations.ShowDifferencesAsUnifiedDiffOperationWC) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IContainer(org.eclipse.core.resources.IContainer) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)69 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)20 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 IResource (org.eclipse.core.resources.IResource)15 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)15 TeamException (org.eclipse.team.core.TeamException)14 ArrayList (java.util.ArrayList)13 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 File (java.io.File)10 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)9 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)8 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)8 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)8 Iterator (java.util.Iterator)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 List (java.util.List)6