Search in sources :

Example 1 with MergeOptions

use of com.collabnet.subversion.merge.MergeOptions in project subclipse by subclipse.

the class ShowRemoteHistoryAction method getSelectedRemoteResources.

protected ISVNRemoteResource[] getSelectedRemoteResources() {
    MergeOutput mergeOutput = null;
    ISVNRemoteResource remoteResource = null;
    Iterator iter = fSelection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof MergeResult) {
            MergeResult mergeResult = (MergeResult) object;
            IResource resource = mergeResult.getResource();
            mergeOutput = mergeResult.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
            try {
                String resourceSubString = resource.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
        if (object instanceof MergeResultsFolder) {
            MergeResultsFolder mergeResultsFolder = (MergeResultsFolder) object;
            IContainer folder = mergeResultsFolder.getFolder();
            mergeOutput = mergeResultsFolder.getMergeOutput();
            MergeOptions mergeOptions = mergeOutput.getMergeOptions();
            SVNUrl svnUrl = mergeOptions.getFromUrl();
            ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(folder);
            try {
                String resourceSubString = folder.getFullPath().toOSString().substring(mergeOutput.getTarget().length() + 1);
                if (!resourceSubString.startsWith("/"))
                    // $NON-NLS-1$ //$NON-NLS-2$
                    resourceSubString = "/" + resourceSubString;
                SVNUrl remoteResourceUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                resourceSubString.replaceAll("\\\\", "/"));
                remoteResource = svnResource.getRepository().getRemoteFile(remoteResourceUrl);
            } catch (Exception e) {
                Activator.handleError(Messages.ShowRemoteHistoryAction_error, e);
                MessageDialog.openError(getShell(), Messages.ShowRemoteHistoryAction_title, e.getLocalizedMessage());
            }
            break;
        }
    }
    if (remoteResource != null) {
        ISVNRemoteResource[] selectedResource = { remoteResource };
        SVNRevision.Number startRevision = null;
        try {
            startRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getLowerRevision()));
        } catch (ParseException e) {
        }
        SVNRevision.Number endRevision = null;
        if (mergeOutput.getUpperRevision() > 0) {
            try {
                endRevision = (SVNRevision.Number) SVNRevision.getRevision(Long.toString(mergeOutput.getUpperRevision()));
            } catch (ParseException e) {
            }
        }
        HistorySearchViewerFilter historySearchViewerFilter = new HistorySearchViewerFilter(null, null, null, null, true, startRevision, endRevision);
        SVNHistoryPage.setHistorySearchViewerFilter(historySearchViewerFilter);
        return selectedResource;
    }
    return new ISVNRemoteResource[0];
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) MergeResult(com.collabnet.subversion.merge.MergeResult) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) ParseException(java.text.ParseException) MergeOutput(com.collabnet.subversion.merge.MergeOutput) Iterator(java.util.Iterator) HistorySearchViewerFilter(org.tigris.subversion.subclipse.ui.history.HistorySearchViewerFilter) MergeOptions(com.collabnet.subversion.merge.MergeOptions) ParseException(java.text.ParseException) IContainer(org.eclipse.core.resources.IContainer) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) IResource(org.eclipse.core.resources.IResource) MergeResultsFolder(com.collabnet.subversion.merge.MergeResultsFolder)

Example 2 with MergeOptions

use of com.collabnet.subversion.merge.MergeOptions in project subclipse by subclipse.

the class CopyFromMergeSourceAction method execute.

protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    Iterator iter = selection.iterator();
    while (iter.hasNext()) {
        Object object = iter.next();
        if (object instanceof ISkippedMergeResult) {
            SVNRevision svnRevision = null;
            IResource resource = null;
            SVNUrl srcUrl = null;
            MergeResult mergeResult = null;
            if (object instanceof SkippedMergeResult) {
                SkippedMergeResult skippedMergeResult = (SkippedMergeResult) object;
                mergeResult = skippedMergeResult;
                MergeOptions mergeOptions = skippedMergeResult.getMergeOutput().getMergeOptions();
                svnRevision = mergeOptions.getToRevision();
                SVNUrl svnUrl = mergeOptions.getFromUrl();
                resource = skippedMergeResult.getResource();
                if (!resource.exists()) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    String resourceSubString = resource.getFullPath().toOSString().substring(skippedMergeResult.getMergeOutput().getTarget().length() + 1);
                    if (!resourceSubString.startsWith("/"))
                        // $NON-NLS-1$ //$NON-NLS-2$
                        resourceSubString = "/" + resourceSubString;
                    try {
                        srcUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                        resourceSubString.replaceAll("\\\\", "/"));
                    } catch (MalformedURLException e) {
                        Activator.handleError(Messages.CopyFromMergeSourceAction_error, e);
                        MessageDialog.openError(getShell(), Messages.CopyFromMergeSourceAction_title, e.getLocalizedMessage());
                        return;
                    }
                }
            }
            if (object instanceof SkippedMergeResultsFolder) {
                SkippedMergeResultsFolder skippedMergeResultsFolder = (SkippedMergeResultsFolder) object;
                mergeResult = skippedMergeResultsFolder.getMergeResult();
                MergeOptions mergeOptions = skippedMergeResultsFolder.getMergeOutput().getMergeOptions();
                svnRevision = mergeOptions.getToRevision();
                SVNUrl svnUrl = mergeOptions.getFromUrl();
                resource = skippedMergeResultsFolder.getFolder();
                if (!resource.exists()) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    String resourceSubString = resource.getFullPath().toOSString().substring(skippedMergeResultsFolder.getMergeOutput().getTarget().length() + 1);
                    if (!resourceSubString.startsWith("/"))
                        // $NON-NLS-1$ //$NON-NLS-2$
                        resourceSubString = "/" + resourceSubString;
                    try {
                        srcUrl = new SVNUrl(svnUrl.toString() + // $NON-NLS-1$ //$NON-NLS-2$
                        resourceSubString.replaceAll("\\\\", "/"));
                    } catch (MalformedURLException e) {
                        Activator.handleError(Messages.CopyFromMergeSourceAction_error2, e);
                        MessageDialog.openError(getShell(), Messages.CopyFromMergeSourceAction_title, e.getLocalizedMessage());
                        return;
                    }
                }
            }
            if (resource.exists()) {
                MessageDialog.openError(getShell(), Messages.CopyFromMergeSourceAction_title, resource.getName() + Messages.CopyFromMergeSourceAction_alreadyExists);
                return;
            }
            if (svnRevision == null)
                svnRevision = SVNRevision.HEAD;
            IResource[] resources = { resource };
            File destPath = new File(resource.getLocation().toOSString());
            CopyOperation copyOperation = new CopyOperation(getTargetPart(), resources, srcUrl, destPath, svnRevision, mergeResult);
            copyOperation.run();
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) SkippedMergeResult(com.collabnet.subversion.merge.SkippedMergeResult) MergeResult(com.collabnet.subversion.merge.MergeResult) ISkippedMergeResult(com.collabnet.subversion.merge.ISkippedMergeResult) SkippedMergeResultsFolder(com.collabnet.subversion.merge.SkippedMergeResultsFolder) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) CopyOperation(com.collabnet.subversion.merge.CopyOperation) Iterator(java.util.Iterator) MergeOptions(com.collabnet.subversion.merge.MergeOptions) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) File(java.io.File) ISkippedMergeResult(com.collabnet.subversion.merge.ISkippedMergeResult) IResource(org.eclipse.core.resources.IResource) SkippedMergeResult(com.collabnet.subversion.merge.SkippedMergeResult) ISkippedMergeResult(com.collabnet.subversion.merge.ISkippedMergeResult)

Aggregations

MergeOptions (com.collabnet.subversion.merge.MergeOptions)2 MergeResult (com.collabnet.subversion.merge.MergeResult)2 Iterator (java.util.Iterator)2 IResource (org.eclipse.core.resources.IResource)2 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)2 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)2 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)2 CopyOperation (com.collabnet.subversion.merge.CopyOperation)1 ISkippedMergeResult (com.collabnet.subversion.merge.ISkippedMergeResult)1 MergeOutput (com.collabnet.subversion.merge.MergeOutput)1 MergeResultsFolder (com.collabnet.subversion.merge.MergeResultsFolder)1 SkippedMergeResult (com.collabnet.subversion.merge.SkippedMergeResult)1 SkippedMergeResultsFolder (com.collabnet.subversion.merge.SkippedMergeResultsFolder)1 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ParseException (java.text.ParseException)1 IContainer (org.eclipse.core.resources.IContainer)1 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)1 HistorySearchViewerFilter (org.tigris.subversion.subclipse.ui.history.HistorySearchViewerFilter)1