Search in sources :

Example 1 with GetStatusCommand

use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.

the class WorkspaceAction method getModifiedResources.

protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    final List modified = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        // get adds, deletes, updates and property updates.
        GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
        command.run(iProgressMonitor);
        ISVNStatus[] statuses = command.getStatuses();
        for (int j = 0; j < statuses.length; j++) {
            if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !SVNStatusUtils.isManaged(statuses[j])) {
                IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
                if (currentResource != null)
                    modified.add(currentResource);
            }
        }
    }
    return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Also used : ArrayList(java.util.ArrayList) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ArrayList(java.util.ArrayList) List(java.util.List) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Example 2 with GetStatusCommand

use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.

the class CommitAction method getModifiedResources.

/**
 * get the modified and unadded resources in resources parameter
 */
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    boolean ignoreHiddenChanges = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES);
    IResource[] allResources = getSelectedResources(true);
    List allSelections = new ArrayList();
    for (int i = 0; i < allResources.length; i++) allSelections.add(allResources[i]);
    List conflictFiles = new ArrayList();
    final List modified = new ArrayList();
    List unversionedFolders = new ArrayList();
    hasUnaddedResources = false;
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        // This check is for when the action is called with unmanaged resources
        if (svnResource.getRepository() == null) {
            continue;
        }
        // if only one resource selected, get url.  Commit dialog displays this.
        if (resources.length == 1) {
            url = svnResource.getStatus().getUrlString();
            if ((url == null) || (resource.getType() == IResource.FILE))
                url = Util.getParentUrl(svnResource);
        }
        boolean descend = true;
        if (resource instanceof IContainer) {
            outer: for (int j = 0; j < allResources.length; j++) {
                if (allResources[j] == resource)
                    continue;
                IContainer parent = allResources[j].getParent();
                while (parent != null) {
                    if (parent.equals(resource)) {
                        descend = false;
                        break outer;
                    }
                    parent = parent.getParent();
                }
            }
        }
        // get adds, deletes, updates and property updates.
        GetStatusCommand command = new GetStatusCommand(svnResource, descend, false);
        command.run(iProgressMonitor);
        ISVNStatus[] statuses = command.getStatuses();
        boolean switched = false;
        for (int j = 0; j < statuses.length; j++) {
            if (SVNStatusUtils.isReadyForCommit(statuses[j]) || SVNStatusUtils.isMissing(statuses[j])) {
                IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
                if (currentResource != null && (descend == true || allSelections.contains(currentResource))) {
                    SVNProviderPlugin.getPlugin().getStatusCacheManager().updateCache(currentResource, statuses[j]);
                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
                    if (!localResource.isIgnored()) {
                        if (!SVNStatusUtils.isManaged(statuses[j])) {
                            if (!Util.isHidden(currentResource)) {
                                hasUnaddedResources = true;
                                if ((currentResource.getType() != IResource.FILE) && !isSymLink(currentResource))
                                    unversionedFolders.add(currentResource);
                                else {
                                    if (!modified.contains(currentResource)) {
                                        modified.add(currentResource);
                                        if (currentResource instanceof IContainer)
                                            statusMap.put(currentResource, statuses[j].getPropStatus());
                                        else
                                            statusMap.put(currentResource, statuses[j].getTextStatus());
                                    }
                                }
                            }
                        } else if (!ignoreHiddenChanges || !Util.isHidden(currentResource)) {
                            if (!modified.contains(currentResource)) {
                                if (statuses[j].isSwitched()) {
                                    switched = true;
                                    url = statuses[j].getUrlString();
                                }
                                modified.add(currentResource);
                                if (currentResource instanceof IContainer)
                                    statusMap.put(currentResource, statuses[j].getPropStatus());
                                else {
                                    statusMap.put(currentResource, statuses[j].getTextStatus());
                                    if (SVNStatusUtils.isTextConflicted(statuses[j])) {
                                        IFile conflictNewFile = (IFile) File2Resource.getResource(statuses[j].getConflictNew());
                                        if (conflictNewFile != null)
                                            conflictFiles.add(conflictNewFile);
                                        IFile conflictOldFile = (IFile) File2Resource.getResource(statuses[j].getConflictOld());
                                        if (conflictOldFile != null)
                                            conflictFiles.add(conflictOldFile);
                                        IFile conflictWorkingFile = (IFile) File2Resource.getResource(statuses[j].getConflictWorking());
                                        if (conflictWorkingFile != null)
                                            conflictFiles.add(conflictWorkingFile);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if (switched && modified.size() > 1) {
            url = null;
        }
    }
    IResource[] unaddedResources = getUnaddedResources(unversionedFolders, iProgressMonitor);
    for (int i = 0; i < unaddedResources.length; i++) if (!modified.contains(unaddedResources[i]))
        modified.add(unaddedResources[i]);
    Iterator iter = conflictFiles.iterator();
    while (iter.hasNext()) {
        IFile conflictFile = (IFile) iter.next();
        modified.remove(conflictFile);
        statusMap.remove(conflictFile);
    }
    return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Also used : IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) Iterator(java.util.Iterator) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ArrayList(java.util.ArrayList) List(java.util.List) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 3 with GetStatusCommand

use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.

the class BaseFolder method getMembers.

/* (non-Javadoc)
   * TODO This should use the synchronization information instead of hitting the WC
   * @see org.tigris.subversion.subclipse.core.resources.RemoteFolder#getMembers(org.eclipse.core.runtime.IProgressMonitor)
   */
protected ISVNRemoteResource[] getMembers(IProgressMonitor monitor) throws SVNException {
    final IProgressMonitor progress = Policy.monitorFor(monitor);
    // $NON-NLS-1$
    progress.beginTask(Policy.bind("RemoteFolder.getMembers"), 100);
    try {
        GetStatusCommand c = new GetStatusCommand(localResourceStatus.getRepository(), resource, false, true);
        c.run(monitor);
        LocalResourceStatus[] statuses = c.getLocalResourceStatuses();
        List<BaseResource> baseChildren = new ArrayList<BaseResource>(statuses.length);
        for (LocalResourceStatus status : statuses) {
            if (localResourceStatus.getFile().equals(status.getFile())) {
                continue;
            }
            // Don't create base entries for files that aren't managed yet
            if (!status.hasRemote()) {
                continue;
            }
            // The folders itself is not its own child, all direct children are
            if (status.getUrlString() != null && !status.getUrlString().equals(localResourceStatus.getUrlString())) {
                BaseResource member = BaseResource.from(SVNWorkspaceRoot.getResourceFor(resource, status), status);
                member.setParent(this);
                baseChildren.add(member);
            }
        }
        return (ISVNRemoteResource[]) baseChildren.toArray(new ISVNRemoteResource[baseChildren.size()]);
    } catch (CoreException e) {
        throw new SVNException(new SVNStatus(IStatus.ERROR, SVNStatus.DOES_NOT_EXIST, Policy.bind("RemoteFolder.doesNotExist", // $NON-NLS-1$
        getRepositoryRelativePath())));
    } finally {
        progress.done();
    }
}
Also used : SVNStatus(org.tigris.subversion.subclipse.core.SVNStatus) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ISVNRemoteResource(org.tigris.subversion.subclipse.core.ISVNRemoteResource) SVNException(org.tigris.subversion.subclipse.core.SVNException)

Example 4 with GetStatusCommand

use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.

the class ResolveTreeConflictWizard method getStatuses.

private ISVNStatus[] getStatuses(boolean getAll) throws SVNException {
    if (statuses == null) {
        IProject project = treeConflict.getResource().getProject();
        if (project == null)
            return new ISVNStatus[0];
        ISVNLocalResource svnProject = SVNWorkspaceRoot.getSVNResourceFor(project);
        GetStatusCommand command = new GetStatusCommand(svnProject, true, getAll);
        command.run(new NullProgressMonitor());
        statuses = command.getStatuses();
    }
    return statuses;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IProject(org.eclipse.core.resources.IProject)

Example 5 with GetStatusCommand

use of org.tigris.subversion.subclipse.core.commands.GetStatusCommand in project subclipse by subclipse.

the class RevertAction method getModifiedResources.

/**
 * get the modified resources in resources parameter
 */
protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    boolean ignoreHiddenChanges = SVNProviderPlugin.getPlugin().getPluginPreferences().getBoolean(ISVNCoreConstants.PREF_IGNORE_HIDDEN_CHANGES);
    // if only one resource selected, get url.  Revert dialog displays this.
    if (resources.length == 1) {
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[0]);
        url = svnResource.getStatus().getUrlString();
        if ((url == null) || (resources[0].getType() == IResource.FILE))
            url = Util.getParentUrl(svnResource);
    }
    ArrayList conflictFiles = new ArrayList();
    final List modified = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        IResource resource = resources[i];
        ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resource);
        // get adds, deletes, updates and property updates.
        GetStatusCommand command = new GetStatusCommand(svnResource, true, false);
        command.run(iProgressMonitor);
        ISVNStatus[] statuses = command.getStatuses();
        for (int j = 0; j < statuses.length; j++) {
            if (statuses[j].isFileExternal() || SVNStatusKind.EXTERNAL.equals(statuses[j].getTextStatus())) {
                includesExternals = true;
            }
            boolean isManaged = SVNStatusUtils.isManaged(statuses[j]);
            if (SVNStatusUtils.isReadyForRevert(statuses[j]) || !isManaged) {
                IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
                if (currentResource != null) {
                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
                    if (!localResource.isIgnored()) {
                        if (isManaged || !Util.isSpecialEclipseFile(currentResource)) {
                            boolean hidden = Util.isHidden(currentResource);
                            if (ignoreHiddenChanges && hidden) {
                                resourcesHidden = true;
                            }
                            if ((!ignoreHiddenChanges && isManaged) || !hidden) {
                                modified.add(currentResource);
                                if (currentResource instanceof IContainer)
                                    statusMap.put(currentResource, statuses[j].getPropStatus());
                                else {
                                    statusMap.put(currentResource, statuses[j].getTextStatus());
                                    if (SVNStatusUtils.isTextConflicted(statuses[j])) {
                                        IFile conflictNewFile = (IFile) File2Resource.getResource(statuses[j].getConflictNew());
                                        if (conflictNewFile != null)
                                            conflictFiles.add(conflictNewFile);
                                        IFile conflictOldFile = (IFile) File2Resource.getResource(statuses[j].getConflictOld());
                                        if (conflictOldFile != null)
                                            conflictFiles.add(conflictOldFile);
                                        IFile conflictWorkingFile = (IFile) File2Resource.getResource(statuses[j].getConflictWorking());
                                        if (conflictWorkingFile != null)
                                            conflictFiles.add(conflictWorkingFile);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    Iterator iter = conflictFiles.iterator();
    while (iter.hasNext()) {
        IFile conflictFile = (IFile) iter.next();
        modified.remove(conflictFile);
        statusMap.remove(conflictFile);
    }
    return (IResource[]) modified.toArray(new IResource[modified.size()]);
}
Also used : IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) GetStatusCommand(org.tigris.subversion.subclipse.core.commands.GetStatusCommand) ArrayList(java.util.ArrayList) List(java.util.List) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) IContainer(org.eclipse.core.resources.IContainer) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Aggregations

GetStatusCommand (org.tigris.subversion.subclipse.core.commands.GetStatusCommand)6 ArrayList (java.util.ArrayList)5 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)5 List (java.util.List)4 IResource (org.eclipse.core.resources.IResource)4 ISVNStatus (org.tigris.subversion.svnclientadapter.ISVNStatus)4 IContainer (org.eclipse.core.resources.IContainer)3 Iterator (java.util.Iterator)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 ISVNRemoteResource (org.tigris.subversion.subclipse.core.ISVNRemoteResource)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 SVNStatus (org.tigris.subversion.subclipse.core.SVNStatus)1