Search in sources :

Example 36 with ISVNClientAdapter

use of org.tigris.subversion.svnclientadapter.ISVNClientAdapter 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 37 with ISVNClientAdapter

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

the class ShowRevisionsDialog method getShowDifferencesAsUnifiedDiffAction.

// get differences as unified diff action (context menu)
private IAction getShowDifferencesAsUnifiedDiffAction() {
    if (showDifferencesAsUnifiedDiffAction == null) {
        showDifferencesAsUnifiedDiffAction = new Action(Policy.bind("HistoryView.showDifferences"), SVNUIPlugin.getPlugin().getImageDescriptor(// $NON-NLS-1$
        ISVNUIConstants.IMG_MENU_DIFF)) {

            public void run() {
                ISelection selection = treeHistoryViewer.getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection ss = (IStructuredSelection) selection;
                ILogEntry currentSelection = (ILogEntry) ss.getFirstElement();
                FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
                dialog.setText("Select Unified Diff Output File");
                dialog.setFileName(// $NON-NLS-1$
                "revision" + currentSelection.getRevision().getNumber() + ".diff");
                String outFile = dialog.open();
                if (outFile != null) {
                    final SVNUrl url = currentSelection.getResource().getUrl();
                    final SVNRevision oldUrlRevision = new SVNRevision.Number(currentSelection.getRevision().getNumber() - 1);
                    final SVNRevision newUrlRevision = currentSelection.getRevision();
                    final File file = new File(outFile);
                    if (file.exists()) {
                        if (!MessageDialog.openQuestion(getShell(), Policy.bind("HistoryView.showDifferences"), Policy.bind("HistoryView.overwriteOutfile", file.getName())))
                            return;
                    }
                    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                        public void run() {
                            ISVNClientAdapter client = null;
                            try {
                                client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                                client.diff(url, oldUrlRevision, newUrlRevision, file, true);
                            } catch (Exception e) {
                                MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
                            } finally {
                                SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                            }
                        }
                    });
                }
            }
        };
    }
    return showDifferencesAsUnifiedDiffAction;
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) FileDialog(org.eclipse.swt.widgets.FileDialog) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 38 with ISVNClientAdapter

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

Example 39 with ISVNClientAdapter

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

the class ShowAnnotationOperation method getSingleEntry.

private String getSingleEntry(ISVNRemoteFile file, Long revLong) {
    ISVNClientAdapter client = null;
    try {
        client = file.getRepository().getSVNClient();
        SVNRevision revision = SVNRevision.getRevision(revLong.toString());
        ISVNLogMessage[] messages = client.getLogMessages(file.getRepository().getRepositoryRoot(), revision, revision, false);
        if (messages.length == 1)
            return messages[0].getMessage();
        else
            return null;
    } catch (Exception e) {
        return null;
    } finally {
        file.getRepository().returnSVNClient(client);
    }
}
Also used : SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) WorkbenchException(org.eclipse.ui.WorkbenchException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 40 with ISVNClientAdapter

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

the class ShowDifferencesAsUnifiedDiffOperation method execute.

protected void execute(IProgressMonitor monitor) throws SVNException, InterruptedException {
    ISVNClientAdapter client = null;
    ISVNRepositoryLocation repository = SVNProviderPlugin.getPlugin().getRepository(fromUrl.toString());
    if (repository != null)
        client = repository.getSVNClient();
    if (client == null)
        client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
    try {
        SVNRevision pegRevision = null;
        if (fromUrl.toString().equals(toUrl.toString()) && localResource != null) {
            if (localResource.getResource() == null)
                pegRevision = SVNRevision.HEAD;
            else {
                IResource resource = localResource.getResource();
                ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                pegRevision = svnResource.getRevision();
            }
        }
        if (pegRevision == null)
            client.diff(fromUrl, fromRevision, toUrl, toRevision, file, true);
        else
            client.diff(fromUrl, pegRevision, fromRevision, toRevision, file, true);
    } catch (SVNClientException e) {
        throw SVNException.wrapException(e);
    } finally {
        monitor.done();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
}
Also used : ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)108 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)67 SVNException (org.tigris.subversion.subclipse.core.SVNException)37 File (java.io.File)28 IResource (org.eclipse.core.resources.IResource)27 CoreException (org.eclipse.core.runtime.CoreException)22 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)21 TeamException (org.eclipse.team.core.TeamException)21 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)20 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)20 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)19 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)19 ArrayList (java.util.ArrayList)18 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 ISVNProperty (org.tigris.subversion.svnclientadapter.ISVNProperty)13 OperationProgressNotifyListener (org.tigris.subversion.subclipse.core.client.OperationProgressNotifyListener)9 IProject (org.eclipse.core.resources.IProject)8 List (java.util.List)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7