Search in sources :

Example 6 with SVNRevision

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

the class ShowDifferencesAsUnifiedDiffDialog method okPressed.

protected void okPressed() {
    success = true;
    final File file = new File(fileText.getText().trim());
    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() {
            try {
                SVNUrl fromUrl = null;
                SVNUrl toUrl = null;
                SVNRevision fromRevision;
                SVNRevision toRevision;
                if (fromHeadButton.getSelection())
                    fromRevision = SVNRevision.HEAD;
                else {
                    int fromRevisionInt = Integer.parseInt(fromRevisionText.getText().trim());
                    long fromRevisionLong = fromRevisionInt;
                    fromRevision = new SVNRevision.Number(fromRevisionLong);
                }
                if (toHeadButton.getSelection())
                    toRevision = SVNRevision.HEAD;
                else {
                    int toRevisionInt = Integer.parseInt(toRevisionText.getText().trim());
                    long toRevisionLong = toRevisionInt;
                    toRevision = new SVNRevision.Number(toRevisionLong);
                }
                if (fromResource == remoteResources[0]) {
                    fromUrl = remoteResources[0].getUrl();
                    toUrl = remoteResources[1].getUrl();
                } else {
                    fromUrl = remoteResources[1].getUrl();
                    toUrl = remoteResources[0].getUrl();
                }
                new ShowDifferencesAsUnifiedDiffOperation(targetPart, fromUrl, fromRevision, toUrl, toRevision, file).run();
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
                success = false;
            }
        }
    });
    if (!success)
        return;
    super.okPressed();
}
Also used : ShowDifferencesAsUnifiedDiffOperation(org.tigris.subversion.subclipse.ui.operations.ShowDifferencesAsUnifiedDiffOperation) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) File(java.io.File)

Example 7 with SVNRevision

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

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

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

Example 10 with SVNRevision

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

the class UpdateSynchronizeOperation method getRevisionForUpdate.

/**
 * This method returns the highest revision number in the set of items being updated or
 * SVNRevision.HEAD if there are deleted items
 *
 * @param resources - the resources being updated
 * @param set - the list of all selected items in synch view
 * @return
 */
private SVNRevision getRevisionForUpdate(IResource[] resources, SyncInfoSet set) {
    SVNRevision revision = null;
    final SyncInfo[] syncInfos = set.getSyncInfos();
    boolean useHEAD = false;
    syncInfoLoop: for (int i = 0; i < syncInfos.length; i++) {
        SVNStatusSyncInfo syncInfo = (SVNStatusSyncInfo) syncInfos[i];
        resourceLoop: for (int j = 0; j < resources.length; j++) {
            if (resources[j].equals(syncInfo.getLocal())) {
                IResourceVariant remote = syncInfo.getRemote();
                if (remote != null && remote instanceof ISVNRemoteResource) {
                    if (syncInfo.getRemoteResourceStatus() != null) {
                        if (syncInfo.getRemoteResourceStatus().getTextStatus() == SVNStatusKind.DELETED) {
                            // update contains deleted items
                            useHEAD = true;
                            break syncInfoLoop;
                        }
                    }
                    SVNRevision rev = ((ISVNRemoteResource) remote).getLastChangedRevision();
                    if (rev instanceof SVNRevision.Number) {
                        long nbr = ((SVNRevision.Number) rev).getNumber();
                        if (revision == null)
                            revision = rev;
                        else {
                            long revisionNumber = ((SVNRevision.Number) revision).getNumber();
                            if (nbr > revisionNumber)
                                revision = rev;
                        }
                    }
                }
                break resourceLoop;
            }
        }
    }
    if (revision == null || useHEAD)
        revision = SVNRevision.HEAD;
    return revision;
}
Also used : SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SVNStatusSyncInfo(org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResourceVariant(org.eclipse.team.core.variants.IResourceVariant)

Aggregations

SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)48 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)22 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)17 IResource (org.eclipse.core.resources.IResource)15 TeamException (org.eclipse.team.core.TeamException)15 SVNException (org.tigris.subversion.subclipse.core.SVNException)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)12 File (java.io.File)9 CoreException (org.eclipse.core.runtime.CoreException)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)9 ArrayList (java.util.ArrayList)8 ISelection (org.eclipse.jface.viewers.ISelection)8 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)8 PartInitException (org.eclipse.ui.PartInitException)7 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 ParseException (java.text.ParseException)6 Action (org.eclipse.jface.action.Action)6