Search in sources :

Example 11 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class LogEntry method updateRootUrl.

/**
 * @param resource
 * @return rootURL
 */
private SVNUrl updateRootUrl(ISVNResource resource) {
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        SVNProviderPlugin.disableConsoleLogging();
        ISVNInfo info = client.getInfo(resource.getUrl());
        SVNProviderPlugin.enableConsoleLogging();
        if (info.getRepository() == null)
            return resource.getUrl();
        else {
            // update the saved root URL
            resource.getRepository().setRepositoryRoot(info.getRepository());
            return info.getRepository();
        }
    } catch (Exception e) {
        SVNProviderPlugin.enableConsoleLogging();
        return resource.getUrl();
    } finally {
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
}
Also used : ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 12 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class SVNRepositoryLocation method fromString.

/*
   * Parse a location string and return a SVNRepositoryLocation.
   * If useRootUrl is true, use the repository root URL.
   */
public static SVNRepositoryLocation fromString(String location, boolean validateOnly, boolean useRootUrl) throws SVNException {
    if (!useRootUrl)
        return fromString(location, validateOnly);
    ISVNClientAdapter svnClient = SVNProviderPlugin.getPlugin().getSVNClient();
    try {
        SVNUrl url = new SVNUrl(location);
        ISVNInfo info = svnClient.getInfo(url);
        SVNUrl rootUrl = info.getRepository();
        return fromString(rootUrl.toString());
    } catch (MalformedURLException e) {
        throw SVNException.wrapException(e);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClient);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 13 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class SVNRepositoryLocation method validateConnection.

/*
   * Validate that the receiver contains valid information for
   * making a connection. If the receiver contains valid
   * information, the method returns. Otherwise, an exception
   * indicating the problem is throw.
   */
public void validateConnection(IProgressMonitor monitor) throws SVNException {
    ISVNClientAdapter svnClient = getSVNClient();
    try {
        // we try to get the list of directories and files using the connection
        ISVNInfo info = svnClient.getInfo(getUrl());
        repositoryRootUrl = info.getRepository();
    } catch (SVNClientException e) {
        // If the validation failed, dispose of any cached info
        dispose();
        throw SVNException.wrapException(e);
    }
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 14 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo 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)

Example 15 with ISVNInfo

use of org.tigris.subversion.svnclientadapter.ISVNInfo in project subclipse by subclipse.

the class SVNPropertyPage method getStatus.

private void getStatus() {
    ISVNRepositoryLocation repository = null;
    ISVNClientAdapter svnClient = null;
    try {
        IResource resource = (IResource) getElement();
        SVNTeamProvider svnProvider = (SVNTeamProvider) RepositoryProvider.getProvider(resource.getProject(), SVNProviderPlugin.getTypeId());
        if (svnProvider == null)
            return;
        svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        if (svnResource == null)
            return;
        status = svnResource.getStatus();
        if (status != null && !status.isIgnored()) {
            repository = svnResource.getRepository();
            svnClient = repository.getSVNClient();
            ISVNInfo info = svnClient.getInfoFromWorkingCopy(svnResource.getFile());
            urlCopiedFrom = info.getCopyUrl();
            revision = svnResource.getRevision();
            lockOwnerText = status.getLockOwner();
            lockCommentText = status.getLockComment();
            if (status.getLockCreationDate() != null)
                lockDateText = status.getLockCreationDate().toString();
            if (!status.isAdded()) {
                try {
                    info = svnClient.getInfo(status.getUrl());
                } catch (Exception e) {
                }
            }
            // Get lock information from server if svn:needs-lock property is set
            if (info != null && status.getLockOwner() == null && status.getUrlString() != null) {
                ISVNProperty prop = svnResource.getSvnProperty("svn:needs-lock");
                if (prop != null) {
                    lockOwnerText = info.getLockOwner();
                    if (info.getLockCreationDate() != null)
                        lockDateText = info.getLockCreationDate().toString();
                    lockCommentText = info.getLockComment();
                }
            }
        }
    } catch (Exception e) {
        SVNUIPlugin.log(new Status(IStatus.ERROR, SVNUIPlugin.ID, TeamException.UNABLE, "Property Exception", // $NON-NLS-1$
        e));
    } finally {
        if (repository != null) {
            repository.returnSVNClient(svnClient);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) Status(org.eclipse.core.runtime.Status) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNTeamProvider(org.tigris.subversion.subclipse.core.SVNTeamProvider) ISVNInfo(org.tigris.subversion.svnclientadapter.ISVNInfo) ISVNProperty(org.tigris.subversion.svnclientadapter.ISVNProperty) IResource(org.eclipse.core.resources.IResource) TeamException(org.eclipse.team.core.TeamException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)26 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 SVNException (org.tigris.subversion.subclipse.core.SVNException)13 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)12 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)8 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)5 IResource (org.eclipse.core.resources.IResource)4 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)4 File (java.io.File)3 MalformedURLException (java.net.MalformedURLException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Alias (org.tigris.subversion.subclipse.core.history.Alias)3 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)3 RevisionGraphEditorInput (org.tigris.subversion.subclipse.graph.editors.RevisionGraphEditorInput)3 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)3 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)2 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)2