Search in sources :

Example 1 with CancelableSVNStatusCallback

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

the class SVNWorkspaceSubscriber method findChanges.

private IResource[] findChanges(IResource resource, int depth, IProgressMonitor monitor) throws TeamException {
    try {
        monitor.beginTask("", 100);
        remoteSyncStateStore.flushBytes(resource, depth);
        // ISVNClientAdapter client = SVNProviderPlugin.getPlugin().createSVNClient();
        boolean descend = (depth == IResource.DEPTH_INFINITE) ? true : false;
        boolean showOutOfDate = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_SHOW_OUT_OF_DATE_FOLDERS);
        StatusAndInfoCommand cmd = new StatusAndInfoCommand(SVNWorkspaceRoot.getSVNResourceFor(resource), descend, showOutOfDate, true);
        cmd.setCallback(new CancelableSVNStatusCallback(monitor));
        cmd.run(monitor);
        if (monitor.isCanceled()) {
            return new IResource[0];
        }
        monitor.worked(70);
        RemoteResourceStatus[] statuses = cmd.getRemoteResourceStatuses();
        List<IResource> result = new ArrayList<IResource>(statuses.length);
        for (RemoteResourceStatus status : statuses) {
            IResource changedResource = SVNWorkspaceRoot.getResourceFor(resource, status);
            if (changedResource == null)
                continue;
            if (isSupervised(changedResource) || (status.getTextStatus() != SVNStatusKind.NONE)) {
                if (!ignoreHiddenChanges || !Util.isHidden(changedResource)) {
                    result.add(changedResource);
                    remoteSyncStateStore.setBytes(changedResource, status.getBytes());
                    registerChangedResourceParent(changedResource);
                }
            }
        }
        // Ensure that the local sync state is also updated
        IContainer container = resource.getType() == IResource.FILE ? resource.getParent() : (IContainer) resource;
        SVNProviderPlugin.getPlugin().getStatusCacheManager().refreshStatus(container, true);
        monitor.worked(30);
        return (IResource[]) result.toArray(new IResource[result.size()]);
    } catch (SVNException e) {
        if (e.getMessage().contains("Operation cancelled")) {
            return new IResource[0];
        } else {
            throw new TeamException("Error getting status for resource " + resource + " " + e.getMessage(), e);
        }
    } finally {
        monitor.done();
    }
}
Also used : RemoteResourceStatus(org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus) TeamException(org.eclipse.team.core.TeamException) CancelableSVNStatusCallback(org.tigris.subversion.subclipse.core.CancelableSVNStatusCallback) ArrayList(java.util.ArrayList) StatusAndInfoCommand(org.tigris.subversion.subclipse.core.client.StatusAndInfoCommand) SVNException(org.tigris.subversion.subclipse.core.SVNException) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 2 with CancelableSVNStatusCallback

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

the class StatusCommand method execute.

protected void execute(final ISVNClientAdapter client, final IProgressMonitor monitor) throws SVNClientException {
    ISVNNotifyListener revisionListener = new ISVNNotifyListener() {

        public void setCommand(int command) {
        }

        public void logCommandLine(String commandLine) {
        }

        public void logMessage(String message) {
        }

        public void logError(String message) {
        }

        public void logRevision(long aRevision, String path) {
            StatusCommand.this.revisions.add(new RevisionsCache(aRevision, path));
            if (StatusCommand.this.revisions.size() > 1) {
                Collections.sort(StatusCommand.this.revisions);
            }
        }

        public void logCompleted(String message) {
        }

        public void onNotify(File path, SVNNodeKind kind) {
        }
    };
    try {
        client.addNotifyListener(revisionListener);
        if (callback != null && callback instanceof CancelableSVNStatusCallback) {
            ((CancelableSVNStatusCallback) callback).setSvnClient(client);
        }
        statuses = client.getStatus(file, descend, getAll, contactServer, false, callback);
    } finally {
        client.removeNotifyListener(revisionListener);
    }
}
Also used : SVNNodeKind(org.tigris.subversion.svnclientadapter.SVNNodeKind) CancelableSVNStatusCallback(org.tigris.subversion.subclipse.core.CancelableSVNStatusCallback) ISVNNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) File(java.io.File)

Aggregations

CancelableSVNStatusCallback (org.tigris.subversion.subclipse.core.CancelableSVNStatusCallback)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1 TeamException (org.eclipse.team.core.TeamException)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 StatusAndInfoCommand (org.tigris.subversion.subclipse.core.client.StatusAndInfoCommand)1 RemoteResourceStatus (org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus)1 ISVNNotifyListener (org.tigris.subversion.svnclientadapter.ISVNNotifyListener)1 SVNNodeKind (org.tigris.subversion.svnclientadapter.SVNNodeKind)1