Search in sources :

Example 1 with RemoteResourceStatus

use of org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus in project subclipse by subclipse.

the class SVNWorkspaceSubscriber method getSyncInfo.

/* (non-Javadoc)
   * @see org.eclipse.team.core.subscribers.Subscriber#getSyncInfo(org.eclipse.core.resources.IResource)
   */
public SyncInfo getSyncInfo(IResource resource) throws TeamException {
    if (resource == null)
        return null;
    if (!isSupervised(resource))
        return null;
    if (ignoreHiddenChanges && Util.isHidden(resource)) {
        return null;
    }
    // LocalResourceStatus localStatus = SVNWorkspaceRoot.getSVNResourceFor( resource );
    LocalResourceStatus localStatus = SVNProviderPlugin.getPlugin().getStatusCacheManager().getStatus(resource);
    RemoteResourceStatus remoteStatusInfo = null;
    byte[] remoteBytes = remoteSyncStateStore.getBytes(resource);
    if ((remoteBytes != null) && (remoteBytes != DUMMY_SYNC_BYTES)) {
        remoteStatusInfo = RemoteResourceStatus.fromBytes(remoteBytes);
    }
    SyncInfo syncInfo = new SVNStatusSyncInfo(resource, localStatus, remoteStatusInfo, comparator);
    syncInfo.init();
    return syncInfo;
}
Also used : RemoteResourceStatus(org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus) SyncInfo(org.eclipse.team.core.synchronize.SyncInfo) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)

Example 2 with RemoteResourceStatus

use of org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus 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 3 with RemoteResourceStatus

use of org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus in project subclipse by subclipse.

the class StatusAndInfoCommand method collectRemoteStatuses.

private RemoteResourceStatus[] collectRemoteStatuses(ISVNStatus[] statuses, ISVNClientAdapter client, final IProgressMonitor monitor) {
    monitor.beginTask("", statuses.length);
    try {
        RemoteResourceStatus[] result = new RemoteResourceStatus[statuses.length];
        Arrays.sort(statuses, new Comparator() {

            public int compare(Object o1, Object o2) {
                return ((ISVNStatus) o1).getPath().compareTo(((ISVNStatus) o2).getPath());
            }
        });
        for (int i = 0; i < statuses.length; i++) {
            ISVNStatus status = statuses[i];
            SVNStatusKind localTextStatus = status.getTextStatus();
            if (SVNStatusKind.UNVERSIONED.equals(localTextStatus) || SVNStatusKind.ADDED.equals(localTextStatus) || SVNStatusKind.IGNORED.equals(localTextStatus)) {
                if (SVNStatusKind.NONE.equals(status.getRepositoryTextStatus()))
                    result[i] = RemoteResourceStatus.NONE;
                else
                    result[i] = new RemoteResourceStatus(statuses[i], getRevisionFor(statuses[i]));
            } else {
                result[i] = new RemoteResourceStatus(statuses[i], getRevisionFor(statuses[i]));
            }
            monitor.worked(1);
        }
        return result;
    } finally {
        monitor.done();
    }
}
Also used : RemoteResourceStatus(org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) SVNStatusKind(org.tigris.subversion.svnclientadapter.SVNStatusKind) Comparator(java.util.Comparator)

Aggregations

RemoteResourceStatus (org.tigris.subversion.subclipse.core.resources.RemoteResourceStatus)3 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 IContainer (org.eclipse.core.resources.IContainer)1 IResource (org.eclipse.core.resources.IResource)1 TeamException (org.eclipse.team.core.TeamException)1 SyncInfo (org.eclipse.team.core.synchronize.SyncInfo)1 CancelableSVNStatusCallback (org.tigris.subversion.subclipse.core.CancelableSVNStatusCallback)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 StatusAndInfoCommand (org.tigris.subversion.subclipse.core.client.StatusAndInfoCommand)1 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)1 ISVNStatus (org.tigris.subversion.svnclientadapter.ISVNStatus)1 SVNStatusKind (org.tigris.subversion.svnclientadapter.SVNStatusKind)1