Search in sources :

Example 46 with SVNRevision

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

the class DifferencesDialog method compare.

private void compare() {
    if (fromResource instanceof ISVNRemoteResource && toResource != null && toResource instanceof ISVNRemoteResource) {
        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);
        }
        try {
            fromUrl = new SVNUrl(fromUrlText.getText().trim());
            toUrl = new SVNUrl(toUrlText.getText().trim());
        } catch (Exception e) {
            MessageDialog.openError(getShell(), Policy.bind("DifferencesDialog.compare"), e.getMessage());
            success = false;
            return;
        }
        ISVNRemoteResource resource1 = null;
        SVNRevision.Number lastChangedRevision1 = null;
        ISVNRemoteResource resource2 = null;
        SVNRevision.Number lastChangedRevision2 = null;
        if (fromRevision instanceof SVNRevision.Number) {
            lastChangedRevision1 = (SVNRevision.Number) fromRevision;
        } else {
            lastChangedRevision1 = ((ISVNRemoteResource) remoteResources[0]).getLastChangedRevision();
        }
        if (fromResource.isFolder()) {
            resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
            if (!fromUrl.equals(fromResource.getUrl())) {
                try {
                    resource1.members(null);
                } catch (TeamException e) {
                    resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
                }
            }
        } else {
            resource1 = new RemoteFile(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
            if (!fromUrl.equals(fromResource.getUrl())) {
                IStorage storage = null;
                try {
                    storage = resource1.getStorage(null);
                } catch (TeamException e) {
                }
                if (storage == null) {
                    resource1 = new RemoteFolder(null, fromResource.getRepository(), fromUrl, fromRevision, lastChangedRevision1, null, null);
                }
            }
        }
        if (fromRevision instanceof SVNRevision.Number) {
            if (usePegRevision && resource1 instanceof RemoteResource) {
                ((RemoteResource) resource1).setPegRevision(fromRevision);
            }
        }
        if (toRevision instanceof SVNRevision.Number) {
            lastChangedRevision2 = (SVNRevision.Number) toRevision;
        } else {
            lastChangedRevision2 = ((ISVNRemoteResource) remoteResources[1]).getLastChangedRevision();
        }
        if (toResource.isFolder()) {
            resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
            if (!toUrl.equals(toResource.getUrl())) {
                try {
                    resource2.members(null);
                } catch (TeamException e) {
                    resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
                }
            }
        } else {
            resource2 = new RemoteFile(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
            if (!toUrl.equals(toResource.getUrl())) {
                IStorage storage = null;
                try {
                    storage = resource2.getStorage(null);
                } catch (TeamException e) {
                }
                if (storage == null) {
                    resource2 = new RemoteFolder(null, toResource.getRepository(), toUrl, toRevision, lastChangedRevision2, null, null);
                }
            }
        }
        if (toRevision instanceof SVNRevision.Number) {
            if (usePegRevision && resource2 instanceof RemoteResource) {
                ((RemoteResource) resource2).setPegRevision(toRevision);
            }
        }
        ISVNRemoteResource[] remotes = { resource1, resource2 };
        CompareRemoteResourcesAction compareAction = new CompareRemoteResourcesAction();
        compareAction.setLocalResource(localResource);
        compareAction.setRemoteResources(remotes);
        compareAction.setPegRevisions(pegRevisions);
        compareAction.setLocalResources(remoteResources);
        try {
            compareAction.execute(null);
        } catch (InvocationTargetException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        } catch (InterruptedException e) {
            SVNUIPlugin.log(IStatus.ERROR, e.getMessage(), e);
        }
    }
}
Also used : RemoteResource(org.tigris.subversion.subclipse.core.resources.RemoteResource) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) CompareRemoteResourcesAction(org.tigris.subversion.subclipse.ui.actions.CompareRemoteResourcesAction) SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) RemoteFolder(org.tigris.subversion.subclipse.core.resources.RemoteFolder) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) IStorage(org.eclipse.core.resources.IStorage) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile)

Example 47 with SVNRevision

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

the class DifferencesDialog method diff.

private void diff() {
    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);
                }
                fromUrl = new SVNUrl(fromUrlText.getText().trim());
                toUrl = new SVNUrl(toUrlText.getText().trim());
                ShowDifferencesAsUnifiedDiffOperation operation = new ShowDifferencesAsUnifiedDiffOperation(targetPart, fromUrl, fromRevision, toUrl, toRevision, file);
                operation.setLocalResource(remoteResources[0]);
                operation.run();
            } catch (Exception e) {
                MessageDialog.openError(getShell(), Policy.bind("HistoryView.showDifferences"), e.getMessage());
                success = false;
            }
        }
    });
}
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) RemoteFile(org.tigris.subversion.subclipse.core.resources.RemoteFile) InvocationTargetException(java.lang.reflect.InvocationTargetException) TeamException(org.eclipse.team.core.TeamException)

Example 48 with SVNRevision

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

the class HistoryDialog method getNextLogEntries.

private void getNextLogEntries() {
    BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

        public void run() {
            try {
                if (remoteResource == null) {
                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
                    if (localResource != null && !localResource.getStatus().isAdded() && localResource.getStatus().isManaged()) {
                        remoteResource = localResource.getBaseResource();
                    }
                }
                if (remoteResource != null) {
                    SVNRevision pegRevision = remoteResource.getRevision();
                    SVNRevision revisionEnd = new SVNRevision.Number(0);
                    boolean stopOnCopy = store.getBoolean(ISVNUIConstants.PREF_STOP_ON_COPY);
                    int entriesToFetch = store.getInt(ISVNUIConstants.PREF_LOG_ENTRIES_TO_FETCH);
                    long limit = entriesToFetch;
                    ILogEntry[] nextEntries = getLogEntries(remoteResource, pegRevision, revisionStart, revisionEnd, stopOnCopy, limit + 1, tagManager);
                    long entriesLength = nextEntries.length;
                    if (entriesLength > limit) {
                        ILogEntry[] fetchedEntries = new ILogEntry[nextEntries.length - 1];
                        for (int i = 0; i < nextEntries.length - 1; i++) fetchedEntries[i] = nextEntries[i];
                        getNextButton.setEnabled(true);
                    } else
                        getNextButton.setEnabled(false);
                    ArrayList entryArray = new ArrayList();
                    if (entries == null)
                        entries = new ILogEntry[0];
                    for (int i = 0; i < entries.length; i++) entryArray.add(entries[i]);
                    for (int i = 0; i < nextEntries.length; i++) entryArray.add(nextEntries[i]);
                    entries = new ILogEntry[entryArray.size()];
                    entryArray.toArray(entries);
                    if (entries.length > 0) {
                        ILogEntry lastEntry = entries[entries.length - 1];
                        long lastEntryNumber = lastEntry.getRevision().getNumber();
                        revisionStart = new SVNRevision.Number(lastEntryNumber - 1);
                    }
                }
            } catch (TeamException e) {
                SVNUIPlugin.openError(Display.getCurrent().getActiveShell(), null, null, e);
            }
        }
    });
    ISelection selection = tableHistoryViewer.getSelection();
    tableHistoryViewer.refresh();
    tableHistoryViewer.setSelection(selection);
}
Also used : TeamException(org.eclipse.team.core.TeamException) ILogEntry(org.tigris.subversion.subclipse.core.history.ILogEntry) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource)

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