Search in sources :

Example 1 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class SVNHistoryPage method getCompareWithPreviousChangedPathAction.

private IAction getCompareWithPreviousChangedPathAction() {
    if (compareWithPreviousChangedPathAction == null) {
        compareWithPreviousChangedPathAction = new Action() {

            public void run() {
                CompareRemoteResourcesAction delegate = new CompareRemoteResourcesAction();
                delegate.init(this);
                ISVNRemoteResource remoteResource1 = null;
                Object firstSelection = ((IStructuredSelection) changePathsViewer.getSelection()).getFirstElement();
                if (firstSelection instanceof LogEntryChangePath) {
                    LogEntryChangePath logEntryChangePath = (LogEntryChangePath) firstSelection;
                    try {
                        remoteResource1 = logEntryChangePath.getRemoteResource();
                    } catch (SVNException e1) {
                        SVNUIPlugin.openError(getSite().getShell(), null, null, e1, SVNUIPlugin.LOG_TEAM_EXCEPTIONS);
                        return;
                    }
                } else if (firstSelection instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) firstSelection;
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath logEntryChangePath = (LogEntryChangePath) children[0];
                        try {
                            SVNUrl svnUrl = logEntryChangePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath()).getUrl();
                            SVNRevision.Number selectedRevision = (SVNRevision.Number) getSelectedRevision();
                            remoteResource1 = new RemoteFolder(null, logEntryChangePath.getLogEntry().getRemoteResource().getRepository(), svnUrl, selectedRevision, selectedRevision, null, null);
                        } catch (Exception e) {
                        }
                    }
                }
                if (remoteResource1 == null) {
                    return;
                }
                int from = Integer.parseInt(remoteResource1.getRevision().toString());
                from--;
                String to = Integer.toString(from);
                SVNRevision toRevision = null;
                try {
                    toRevision = SVNRevision.getRevision(to);
                } catch (ParseException e) {
                }
                ISVNRemoteResource[] remoteResources = new ISVNRemoteResource[2];
                ISVNRemoteResource remoteResource2;
                if (firstSelection instanceof HistoryFolder || remoteResource1.getResource() instanceof IContainer) {
                    remoteResource2 = new RemoteFolder(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                } else {
                    remoteResource2 = new RemoteFile(null, remoteResource1.getRepository(), remoteResource1.getUrl(), (SVNRevision.Number) toRevision, (SVNRevision.Number) toRevision, null, null);
                }
                remoteResources[0] = remoteResource1;
                remoteResources[1] = remoteResource2;
                delegate.selectionChanged(this, new StructuredSelection(remoteResources));
                delegate.setRemoteResources(remoteResources);
                delegate.setLocalResource(remoteResource1.getResource());
                delegate.setLocalResources(remoteResources);
                SVNRevision[] pegRevisions = { remoteResource1.getRevision() };
                delegate.setPegRevisions(pegRevisions);
                delegate.run(this);
            }
        };
    }
    return compareWithPreviousChangedPathAction;
}
Also used : CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) ExportRemoteFolderAction(org.tigris.subversion.subclipse.ui.actions.ExportRemoteFolderAction) ShowDifferencesAsUnifiedDiffAction(org.tigris.subversion.subclipse.ui.actions.ShowDifferencesAsUnifiedDiffAction) TextViewerAction(org.tigris.subversion.subclipse.ui.console.TextViewerAction) ShowAnnotationAction(org.tigris.subversion.subclipse.ui.actions.ShowAnnotationAction) ShowHistoryAction(org.tigris.subversion.subclipse.ui.actions.ShowHistoryAction) WorkspaceAction(org.tigris.subversion.subclipse.ui.actions.WorkspaceAction) IAction(org.eclipse.jface.action.IAction) OpenRemoteFileAction(org.tigris.subversion.subclipse.ui.actions.OpenRemoteFileAction) GenerateChangeLogAction(org.tigris.subversion.subclipse.ui.actions.GenerateChangeLogAction) Action(org.eclipse.jface.action.Action) CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) ParseException(java.text.ParseException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IContainer(org.eclipse.core.resources.IContainer) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile)

Example 2 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class MergeWizardRevisionsPage method compareRevisions.

private void compareRevisions() {
    IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
    Object sel0 = sel.getFirstElement();
    if (sel0 instanceof LogEntryChangePath) {
        LogEntryChangePath logEntryChangePath = (LogEntryChangePath) sel0;
        try {
            if (!logEntryChangePath.getRemoteResource().isContainer()) {
                ISVNRemoteResource left = logEntryChangePath.getRemoteResource();
                compareInput = compareInputMap.get(left.getUrl().toString() + left.getRevision());
                boolean run = compareInput == null;
                if (compareInput == null) {
                    SVNRevision.Number selectedRevision = (SVNRevision.Number) left.getRevision();
                    SVNRevision.Number previousRevision = new SVNRevision.Number(selectedRevision.getNumber() - 1);
                    ISVNRemoteResource right = new RemoteFile(left.getRepository(), left.getUrl(), previousRevision);
                    compareInput = new SVNCompareEditorInput(new ResourceEditionNode(left), new ResourceEditionNode(right));
                    compareInputMap.put(left.getUrl().toString() + left.getRevision(), compareInput);
                }
                setCompareInput(compareInput, run);
                showComparePane(true);
            }
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Messages.MergeWizardRevisionsPage_5, e.getMessage());
        }
    }
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) ResourceEditionNode(org.tigris.subversion.subclipse.ui.compare.ResourceEditionNode) SVNCompareEditorInput(org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) SVNException(org.tigris.subversion.subclipse.core.SVNException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) MalformedURLException(java.net.MalformedURLException)

Example 3 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class MergeWizardUnblockRevisionsPage method compareRevisions.

private void compareRevisions() {
    IStructuredSelection sel = (IStructuredSelection) changePathsViewer.getSelection();
    Object sel0 = sel.getFirstElement();
    if (sel0 instanceof LogEntryChangePath) {
        LogEntryChangePath logEntryChangePath = (LogEntryChangePath) sel0;
        try {
            if (!logEntryChangePath.getRemoteResource().isContainer()) {
                ISVNRemoteResource left = logEntryChangePath.getRemoteResource();
                compareInput = compareInputMap.get(left.getUrl().toString() + left.getRevision());
                boolean run = compareInput == null;
                if (compareInput == null) {
                    SVNRevision.Number selectedRevision = (SVNRevision.Number) left.getRevision();
                    SVNRevision.Number previousRevision = new SVNRevision.Number(selectedRevision.getNumber() - 1);
                    ISVNRemoteResource right = new RemoteFile(left.getRepository(), left.getUrl(), previousRevision);
                    compareInput = new SVNCompareEditorInput(new ResourceEditionNode(left), new ResourceEditionNode(right));
                    compareInputMap.put(left.getUrl().toString() + left.getRevision(), compareInput);
                }
                setCompareInput(compareInput, run);
                showComparePane(true);
            }
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Messages.MergeWizardRevisionsPage_5, e.getMessage());
        }
    }
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) ResourceEditionNode(org.tigris.subversion.subclipse.ui.compare.ResourceEditionNode) SVNCompareEditorInput(org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException)

Example 4 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class Util method getUrlForRevision.

public static SVNUrl getUrlForRevision(ISVNRemoteResource resource, SVNRevision.Number revision, IProgressMonitor pm) throws SVNException {
    SVNUrl url = resource.getUrl();
    SVNRevision revisionStart = new SVNRevision.Number(revision.getNumber());
    GetLogsCommand getLogsCommand = new GetLogsCommand(resource, SVNRevision.HEAD, revisionStart, SVNRevision.HEAD, false, 0, null, true);
    getLogsCommand.run(pm);
    ILogEntry[] logEntries = getLogsCommand.getLogEntries();
    String path = resource.getRepositoryRelativePath().replaceAll("%20", " ");
    for (int i = logEntries.length - 1; i > -1; i--) {
        ILogEntry logEntry = logEntries[i];
        if (!logEntry.getRevision().equals(revision)) {
            LogEntryChangePath[] changePaths = logEntry.getLogEntryChangePaths();
            for (LogEntryChangePath changePath : changePaths) {
                if (changePath.getPath().equals(path) && changePath.getCopySrcPath() != null) {
                    try {
                        path = changePath.getCopySrcPath();
                        url = new SVNUrl(resource.getRepository().getRepositoryRoot().toString() + changePath.getCopySrcPath());
                    } catch (MalformedURLException e) {
                    }
                }
            }
        }
    }
    return url;
}
Also used : MalformedURLException(java.net.MalformedURLException) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) GetLogsCommand(org.tigris.subversion.subclipse.core.commands.GetLogsCommand) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 5 with LogEntryChangePath

use of org.tigris.subversion.subclipse.core.history.LogEntryChangePath in project subclipse by subclipse.

the class SVNHistoryPage method getCreateTagFromRevisionChangedPathAction.

private IAction getCreateTagFromRevisionChangedPathAction() {
    if (createTagFromRevisionChangedPathAction == null) {
        createTagFromRevisionChangedPathAction = new // $NON-NLS-1$
        Action() {

            public void run() {
                SVNRevision selectedRevision = null;
                ISelection selection = changePathsViewer.getSelection();
                if (!(selection instanceof IStructuredSelection))
                    return;
                IStructuredSelection sel = (IStructuredSelection) selection;
                ISVNRemoteResource remoteResource = null;
                if (sel.getFirstElement() instanceof LogEntryChangePath) {
                    try {
                        remoteResource = ((LogEntryChangePath) sel.getFirstElement()).getRemoteResource();
                        selectedRevision = remoteResource.getRevision();
                    } catch (SVNException e) {
                    }
                } else if (sel.getFirstElement() instanceof HistoryFolder) {
                    HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                    Object[] children = historyFolder.getChildren();
                    if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                        LogEntryChangePath changePath = (LogEntryChangePath) children[0];
                        try {
                            remoteResource = changePath.getRemoteResource().getRepository().getRemoteFolder(historyFolder.getPath());
                            selectedRevision = getSelectedRevision();
                        } catch (SVNException e) {
                        }
                    }
                }
                if (remoteResource == null)
                    return;
                ISVNRemoteResource[] remoteResources = { remoteResource };
                BranchTagWizard wizard = new BranchTagWizard(remoteResources);
                wizard.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
                WizardDialog dialog = new ClosableWizardDialog(getSite().getShell(), wizard);
                if (dialog.open() == WizardDialog.OK) {
                    final SVNUrl sourceUrl = wizard.getUrl();
                    final SVNUrl destinationUrl = wizard.getToUrl();
                    final String message = wizard.getComment();
                    final SVNRevision revision = wizard.getRevision();
                    final boolean makeParents = wizard.isMakeParents();
                    try {
                        BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                            public void run() {
                                ISVNClientAdapter client = null;
                                try {
                                    client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
                                    client.copy(sourceUrl, destinationUrl, message, revision, makeParents);
                                    SVNUIPlugin.getPlugin().getRepositoryManager().resourceCreated(null, null);
                                } catch (Exception e) {
                                    MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                                    e.getMessage());
                                } finally {
                                    SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
                                }
                            }
                        });
                    } catch (Exception e) {
                        MessageDialog.openError(getSite().getShell(), Policy.bind("HistoryView.createTagFromRevision"), // $NON-NLS-1$
                        e.getMessage());
                    }
                }
            // SvnWizardBranchTagPage branchTagPage = new
            // SvnWizardBranchTagPage(remoteResource);
            // 
            // branchTagPage.setRevisionNumber(Long.parseLong(selectedRevision.toString()));
            // SvnWizard wizard = new SvnWizard(branchTagPage);
            // SvnWizardDialog dialog = new SvnWizardDialog(getSite().getShell(),
            // wizard);
            // wizard.setParentDialog(dialog);
            // if (!(dialog.open() == SvnWizardDialog.OK)) return;
            // final SVNUrl sourceUrl = branchTagPage.getUrl();
            // final SVNUrl destinationUrl = branchTagPage.getToUrl();
            // final String message = branchTagPage.getComment();
            // final SVNRevision revision = branchTagPage.getRevision();
            // final boolean makeParents = branchTagPage.isMakeParents();
            // try {
            // BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
            // public void run() {
            // try {
            // ISVNClientAdapter client =
            // SVNProviderPlugin.getPlugin().getSVNClientManager().createSVNClient();
            // client.copy(sourceUrl, destinationUrl, message, revision,
            // makeParents);
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            // }
            // });
            // } catch(Exception e) {
            // MessageDialog.openError(getSite().getShell(),
            // Policy.bind("HistoryView.createTagFromRevision"), e
            // .getMessage());
            // }
            }
        };
    }
    ISelection selection = changePathsViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sel = (IStructuredSelection) selection;
        SVNRevision selectedRevision = null;
        if (sel.size() == 1) {
            // ISVNRemoteResource remoteResource = null;
            if (sel.getFirstElement() instanceof LogEntryChangePath && ((LogEntryChangePath) sel.getFirstElement()).getAction() != 'D') {
                // try {
                // remoteResource = ((LogEntryChangePath)sel.getFirstElement()).getRemoteResource();
                selectedRevision = ((LogEntryChangePath) sel.getFirstElement()).getRevision();
            // selectedRevision = remoteResource.getRevision();
            // } catch (SVNException e) {}
            } else if (sel.getFirstElement() instanceof HistoryFolder) {
                HistoryFolder historyFolder = (HistoryFolder) sel.getFirstElement();
                Object[] children = historyFolder.getChildren();
                if (children != null && children.length > 0 && children[0] instanceof LogEntryChangePath) {
                    selectedRevision = getSelectedRevision();
                }
            }
            createTagFromRevisionChangedPathAction.setEnabled(selectedRevision != null);
            if (selectedRevision == null) {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + ((LogEntryChangePath) sel.getFirstElement()).getRevision()));
            } else {
                createTagFromRevisionChangedPathAction.setText(Policy.bind("HistoryView.createTagFromRevision", // $NON-NLS-1$ //$NON-NLS-2$
                "" + selectedRevision));
            }
        }
    }
    createTagFromRevisionChangedPathAction.setImageDescriptor(SVNUIPlugin.getPlugin().getImageDescriptor(ISVNUIConstants.IMG_MENU_BRANCHTAG));
    return createTagFromRevisionChangedPathAction;
}
Also used : LogEntryChangePath(org.tigris.subversion.subclipse.core.history.LogEntryChangePath) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException) CoreException(org.eclipse.core.runtime.CoreException) SVNException(org.tigris.subversion.subclipse.core.SVNException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) ParseException(java.text.ParseException) BranchTagWizard(org.tigris.subversion.subclipse.ui.wizards.BranchTagWizard) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) ISelection(org.eclipse.jface.viewers.ISelection) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) WizardDialog(org.eclipse.jface.wizard.WizardDialog) ClosableWizardDialog(org.tigris.subversion.subclipse.ui.wizards.ClosableWizardDialog) SvnWizardDialog(org.tigris.subversion.subclipse.ui.wizards.dialogs.SvnWizardDialog) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

LogEntryChangePath (org.tigris.subversion.subclipse.core.history.LogEntryChangePath)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 TeamException (org.eclipse.team.core.TeamException)5 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)4 SVNException (org.tigris.subversion.subclipse.core.SVNException)4 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)4 ParseException (java.text.ParseException)3 CoreException (org.eclipse.core.runtime.CoreException)3 PartInitException (org.eclipse.ui.PartInitException)3 ISVNRemoteFile (org.tigris.subversion.subclipse.core.ISVNRemoteFile)3 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)3 MalformedURLException (java.net.MalformedURLException)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)2 ResourceEditionNode (org.tigris.subversion.subclipse.ui.compare.ResourceEditionNode)2 SVNCompareEditorInput (org.tigris.subversion.subclipse.ui.compare.SVNCompareEditorInput)2 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)2