Search in sources :

Example 21 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.

the class RevisionAwareDifferencer method compareEditions.

/**
 * Compares two nodes to determine if they are equal. Returns NODE_EQUAL of they are the same,
 * NODE_NOT_EQUAL if they are different, and NODE_UNKNOWN if comparison was not possible.
 */
protected int compareEditions(Object left, Object right) {
    // calculate the type for the left contribution
    ISVNRemoteResource leftEdition = null;
    if (left instanceof ResourceEditionNode) {
        leftEdition = ((ResourceEditionNode) left).getRemoteResource();
    }
    // calculate the type for the right contribution
    ISVNRemoteResource rightEdition = null;
    if (right instanceof ResourceEditionNode)
        rightEdition = ((ResourceEditionNode) right).getRemoteResource();
    if (leftEdition == null || rightEdition == null) {
        return NODE_UNKNOWN;
    }
    // if they're both non-files, they're the same
    if (leftEdition.isContainer() && rightEdition.isContainer()) {
        return NODE_EQUAL;
    }
    // if they have different types, they're different
    if (leftEdition.isContainer() != rightEdition.isContainer()) {
        return NODE_NOT_EQUAL;
    }
    String leftLocation = leftEdition.getRepository().getLocation();
    String rightLocation = rightEdition.getRepository().getLocation();
    if (!leftLocation.equals(rightLocation)) {
        return NODE_UNKNOWN;
    }
    if (leftEdition.getUrl().equals(rightEdition.getUrl()) && leftEdition.getLastChangedRevision().equals(rightEdition.getLastChangedRevision())) {
        return NODE_EQUAL;
    } else {
        // if(considerContentIfRevisionOrPathDiffers()) {
        return NODE_UNKNOWN;
    // } else {
    // return NODE_NOT_EQUAL;
    // }
    }
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource)

Example 22 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.

the class SVNCompareEditorInput method getLabel.

/**
 * Returns the label for the given input element (which is a ResourceEditionNode).
 */
private String getLabel(ITypedElement element) {
    if (element instanceof ResourceEditionNode) {
        ISVNRemoteResource edition = ((ResourceEditionNode) element).getRemoteResource();
        SVNRevision revision = edition.getLastChangedRevision();
        if (revision == null) {
            revision = edition.getRevision();
        }
        if (edition instanceof ISVNRemoteFile) {
            return Policy.bind("nameAndRevision", edition.getName(), // $NON-NLS-1$
            revision.toString());
        }
        if (edition.isContainer()) {
            // $NON-NLS-1$
            return Policy.bind("SVNCompareEditorInput.inHead", edition.getName());
        } else {
            return Policy.bind("SVNCompareEditorInput.repository", // $NON-NLS-1$
            new Object[] { edition.getName(), revision.toString() });
        }
    }
    return element.getName();
}
Also used : ISVNRemoteFile(org.tigris.subversion.subclipse.core.ISVNRemoteFile) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 23 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource in project subclipse by subclipse.

the class SVNCompareEditorInput method getVersionLabel.

/**
 * Returns the label for the given input element. (which is a ResourceEditionNode)
 */
private String getVersionLabel(ITypedElement element) {
    if (element instanceof ResourceEditionNode) {
        ISVNRemoteResource edition = ((ResourceEditionNode) element).getRemoteResource();
        SVNRevision revision = edition.getLastChangedRevision();
        if (revision == null) {
            revision = edition.getRevision();
        }
        if (edition.isContainer()) {
            // $NON-NLS-1$
            return Policy.bind("SVNCompareEditorInput.headLabel");
        } else {
            return revision.toString();
        }
    }
    return element.getName();
}
Also used : ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision)

Example 24 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource 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 25 with ISVNRemoteResource

use of org.tigris.subversion.subclipse.core.ISVNRemoteResource 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)

Aggregations

ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)69 SVNException (org.tigris.subversion.subclipse.core.SVNException)23 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)21 InvocationTargetException (java.lang.reflect.InvocationTargetException)16 TeamException (org.eclipse.team.core.TeamException)16 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)16 IResource (org.eclipse.core.resources.IResource)15 ILogEntry (org.tigris.subversion.subclipse.core.history.ILogEntry)14 ArrayList (java.util.ArrayList)12 ParseException (java.text.ParseException)11 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)10 CoreException (org.eclipse.core.runtime.CoreException)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 ISVNRepositoryLocation (org.tigris.subversion.subclipse.core.ISVNRepositoryLocation)8 MalformedURLException (java.net.MalformedURLException)7 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)7 RemoteFile (org.tigris.subversion.subclipse.core.resources.RemoteFile)7 HistoryDialog (org.tigris.subversion.subclipse.ui.dialogs.HistoryDialog)6 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)6