Search in sources :

Example 66 with SVNUrl

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

the class MergeOutput method resume.

public void resume() {
    IDialogSettings settings = Activator.getDefault().getDialogSettings();
    IResource[] resources = { resource };
    SVNUrl[] fromUrls = { mergeOptions.getFromUrl() };
    SVNUrl[] toUrls = { mergeOptions.getToUrl() };
    MergeOperation mergeOperation = new MergeOperation(SVNUIPlugin.getActivePage().getActivePart(), resources, fromUrls, mergeOptions.getFromRevision(), toUrls, mergeOptions.getToRevision(), mergeOptions.getRevisions(), this);
    mergeOperation.setForce(mergeOptions.isForce());
    mergeOperation.setIgnoreAncestry(mergeOptions.isIgnoreAncestry());
    mergeOperation.setDepth(mergeOptions.getDepth());
    int lastTextConflictChoice = ISVNConflictResolver.Choice.chooseMerged;
    try {
        lastTextConflictChoice = settings.getInt(LAST_TEXT_CONFLICT_CHOICE);
    } catch (Exception e) {
    }
    int lastPropertyConflictChoice = lastTextConflictChoice;
    try {
        lastPropertyConflictChoice = settings.getInt(LAST_PROPERTY_CONFLICT_CHOICE);
    } catch (Exception e) {
    }
    int lastBinaryConflictChoice = ISVNConflictResolver.Choice.chooseMerged;
    try {
        lastBinaryConflictChoice = settings.getInt(LAST_BINARY_CONFLICT_CHOICE);
    } catch (Exception e) {
    }
    int lastTreeConflictChoice = ISVNConflictResolver.Choice.postpone;
    try {
        lastTreeConflictChoice = settings.getInt(LAST_TREE_CONFLICT_CHOICE);
    } catch (Exception e) {
    }
    mergeOperation.setTextConflictHandling(lastTextConflictChoice);
    mergeOperation.setBinaryConflictHandling(lastBinaryConflictChoice);
    mergeOperation.setPropertyConflictHandling(lastPropertyConflictChoice);
    mergeOperation.setTreeConflictHandling(lastTreeConflictChoice);
    try {
        mergeOperation.run();
    } catch (Exception e) {
        Activator.handleError(Messages.MergeOutput_resumeError, e);
        MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.MergeOutput_resume, e.getMessage());
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) IResource(org.eclipse.core.resources.IResource) IOException(java.io.IOException)

Example 67 with SVNUrl

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

Example 68 with SVNUrl

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

the class BranchTagWizardCopyPage method showLog.

private void showLog() {
    ISVNRemoteResource remoteResource = null;
    if (((BranchTagWizard) getWizard()).multipleSelections()) {
        ISVNRepositoryLocation repository = null;
        if (resource == null)
            repository = this.remoteResource.getRepository();
        else
            repository = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository();
        try {
            remoteResource = repository.getRemoteFile(new SVNUrl(((BranchTagWizard) getWizard()).getCommonRoot()));
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
            e.toString());
            return;
        }
    } else {
        if (resource == null)
            remoteResource = this.remoteResource;
        else {
            try {
                remoteResource = SVNWorkspaceRoot.getSVNResourceFor(resource).getRepository().getRemoteFile(((BranchTagWizard) getWizard()).getUrl());
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), // $NON-NLS-1$
                e.toString());
                return;
            }
        }
        if (remoteResource == null) {
            MessageDialog.openError(getShell(), Policy.bind("MergeDialog.showLog"), Policy.bind("MergeDialog.urlError") + " " + ((BranchTagWizard) getWizard()).getUrlText());
            return;
        }
    }
    HistoryDialog dialog = new HistoryDialog(getShell(), remoteResource);
    if (dialog.open() == HistoryDialog.CANCEL)
        return;
    ILogEntry[] selectedEntries = dialog.getSelectedLogEntries();
    if (selectedEntries.length == 0)
        return;
    revisionText.setText(Long.toString(selectedEntries[selectedEntries.length - 1].getRevision().getNumber()));
    setPageComplete(canFinish());
}
Also used : HistoryDialog(org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog) ISVNRepositoryLocation(org.tigris.subversion.subclipse.core.ISVNRepositoryLocation) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 69 with SVNUrl

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

the class ProjectProperties method resolveUrl.

private static String resolveUrl(String url, ISVNLocalResource svnResource) {
    String resolvedUrl = null;
    // Relative to repository root, with navigators.
    if (url.startsWith("^/")) {
        SVNUrl repositoryUrl = svnResource.getRepository().getUrl();
        String path = url.substring(1);
        while (path.startsWith("/..")) {
            if (repositoryUrl.getParent() == null)
                break;
            repositoryUrl = repositoryUrl.getParent();
            path = path.substring(3);
        }
        resolvedUrl = repositoryUrl + path;
    } else // Relative to host.
    if (url.startsWith("/")) {
        String resourceUrl = svnResource.getUrl().toString();
        String protocol = svnResource.getUrl().getProtocol();
        int start = protocol.length();
        while (resourceUrl.substring(start, start + 1).equals(":") || resourceUrl.substring(start, start + 1).equals("/")) start++;
        int end = resourceUrl.indexOf("/", start);
        if (end == -1)
            resolvedUrl = resourceUrl + url;
        else
            resolvedUrl = resourceUrl.substring(0, end) + url;
    } else
        // Non-relative
        resolvedUrl = url;
    return resolvedUrl;
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl)

Example 70 with SVNUrl

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

the class ShowDifferencesAsUnifiedDiffAction method execute.

// 
// private IResource localResource;
// 
// public void setLocalResource(IResource localResource) {
// this.localResource = localResource;
// }
protected void execute(IAction action) throws InvocationTargetException, InterruptedException {
    pegRevision1 = null;
    pegRevision2 = null;
    String fromRevision = null;
    String toRevision = null;
    ISVNResource[] selectedResources = getSelectedRemoteResources();
    SVNUrl fromUrl = null;
    SVNUrl toUrl = null;
    if (selectedResources == null || (selectedResources.length == 0)) {
        Object[] selectedObjects = selection.toArray();
        if (selectedObjects[0] instanceof ILogEntry) {
            selectedResources = new ISVNResource[2];
            selectedResources[0] = ((ILogEntry) selectedObjects[0]).getResource();
            fromRevision = ((ILogEntry) selectedObjects[0]).getRevision().toString();
            ILogEntry logEntry1 = (ILogEntry) selectedObjects[0];
            RemoteResource remoteResource;
            IResource resource1 = logEntry1.getResource().getResource();
            if (resource1 != null) {
                try {
                    ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource1);
                    if (baseResource != null) {
                        pegRevision1 = baseResource.getLastChangedRevision();
                    }
                } catch (Exception e) {
                }
            }
            if (logEntry1.getResource().getResource() instanceof IContainer) {
                remoteResource = new RemoteFolder(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            } else {
                remoteResource = new RemoteFile(logEntry1.getResource().getRepository(), logEntry1.getResource().getUrl(), logEntry1.getRevision());
            }
            fromUrl = remoteResource.getUrl();
            if (selectedObjects.length > 1) {
                selectedResources[1] = ((ILogEntry) selectedObjects[1]).getResource();
                toRevision = ((ILogEntry) selectedObjects[1]).getRevision().toString();
                ILogEntry logEntry2 = (ILogEntry) selectedObjects[1];
                IResource resource2 = logEntry2.getResource().getResource();
                if (resource2 != null) {
                    try {
                        ISVNRemoteResource baseResource = SVNWorkspaceRoot.getBaseResourceFor(resource2);
                        if (baseResource != null) {
                            pegRevision2 = baseResource.getLastChangedRevision();
                        }
                    } catch (Exception e) {
                    }
                }
                if (logEntry2.getResource().getResource() instanceof IContainer) {
                    remoteResource = new RemoteFolder(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                } else {
                    remoteResource = new RemoteFile(logEntry2.getResource().getRepository(), logEntry2.getResource().getUrl(), logEntry2.getRevision());
                }
                toUrl = remoteResource.getUrl();
            } else {
                int from = Integer.parseInt(fromRevision);
                from--;
                toRevision = Integer.toString(from);
                toUrl = remoteResource.getUrl();
            }
        }
    } else {
        if (selectedResources[0] instanceof ISVNRemoteResource)
            fromRevision = ((ISVNRemoteResource) selectedResources[0]).getRevision().toString();
        if (selectedResources.length > 1 && selectedResources[1] instanceof ISVNRemoteResource)
            toRevision = ((ISVNRemoteResource) selectedResources[1]).getRevision().toString();
    }
    if (pegRevision1 == null) {
        pegRevision1 = SVNRevision.HEAD;
    }
    if (pegRevision2 == null) {
        pegRevision2 = pegRevision1;
    }
    DifferencesDialog dialog = new DifferencesDialog(getShell(), null, selectedResources, new SVNRevision[] { pegRevision1, pegRevision2 }, getTargetPart());
    dialog.setUsePegRevision(usePegRevision);
    dialog.setFromUrl(fromUrl);
    dialog.setToUrl(toUrl);
    IResource localResource = null;
    IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    if (part instanceof GenericHistoryView) {
        IHistoryPage historyPage = ((GenericHistoryView) part).getHistoryPage();
        if (historyPage instanceof SVNHistoryPage) {
            localResource = ((SVNHistoryPage) historyPage).getResource();
        }
    }
    dialog.setLocalResource(localResource);
    // $NON-NLS-1$
    if (!fromRevision.equals("HEAD"))
        dialog.setFromRevision(fromRevision);
    if (toRevision != null && !toRevision.equals("HEAD"))
        // $NON-NLS-1$
        dialog.setToRevision(toRevision);
    dialog.open();
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNResource(org.tigris.subversion.subclipse.core.ISVNResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) IHistoryPage(org.eclipse.team.ui.history.IHistoryPage) DifferencesDialog(org.tigris.subversion.subclipse.ui.dialogs.DifferencesDialog) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SVNHistoryPage(org.tigris.subversion.subclipse.ui.history.SVNHistoryPage) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Aggregations

SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)83 SVNException (org.tigris.subversion.subclipse.core.SVNException)29 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)26 MalformedURLException (java.net.MalformedURLException)25 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)21 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)19 ParseException (java.text.ParseException)18 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)17 IResource (org.eclipse.core.resources.IResource)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)14 TeamException (org.eclipse.team.core.TeamException)13 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)13 ArrayList (java.util.ArrayList)12 ISVNInfo (org.tigris.subversion.svnclientadapter.ISVNInfo)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 RemoteFolder (org.tigris.subversion.subclipse.core.resources.RemoteFolder)8