Search in sources :

Example 11 with ISVNStatus

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

the class RecursiveStatusUpdateStrategy method statusesToUpdate.

/* (non-Javadoc)
   * @see org.tigris.subversion.subclipse.core.status.StatusUpdateStrategy#statusesToUpdate(org.eclipse.core.resources.IResource)
   */
protected ISVNStatus[] statusesToUpdate(IResource resource) throws SVNException {
    if (!(resource instanceof IProject)) {
        // if the status of the resource parent is not known, we
        // recursively update it instead
        IContainer parent = resource.getParent();
        if (parent != null) {
            if (statusCache.getStatus(parent) == null) {
                return statusesToUpdate(parent);
            }
        }
    }
    if (Policy.DEBUG_STATUS) {
        // $NON-NLS-1$
        System.out.println("[svn] getting status for : " + resource.getFullPath());
    }
    // don't do getRepository().getSVNClient() as we can ask the status of a file
    // that is not associated with a known repository
    // we don't need login & password so this is not a problem
    ISVNStatus[] statuses = null;
    ISVNClientAdapter svnClientAdapterStatus = null;
    try {
        SVNProviderPlugin.disableConsoleLogging();
        svnClientAdapterStatus = SVNProviderPlugin.getPlugin().getSVNClient();
        statuses = svnClientAdapterStatus.getStatus(resource.getLocation().toFile(), true, true);
    } catch (SVNClientException e1) {
        if (!e1.getMessage().contains(SVNProviderPlugin.UPGRADE_NEEDED)) {
            throw SVNException.wrapException(e1);
        }
    } finally {
        SVNProviderPlugin.enableConsoleLogging();
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(svnClientAdapterStatus);
    }
    return collectUnversionedFolders(statuses, true);
}
Also used : SVNClientException(org.tigris.subversion.svnclientadapter.SVNClientException) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 12 with ISVNStatus

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

the class MergeWizardBestPracticesPage method performChecks.

public void performChecks(boolean refreshPage) {
    try {
        getContainer().run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                needsChecks = false;
                localMods = false;
                switchedChildren = false;
                mixedRevisions = false;
                incompleteWorkingCopy = false;
                localModsList = new ArrayList();
                switchedChildrenList = new ArrayList();
                mixedRevisionsList = new ArrayList();
                incompleteList = new ArrayList();
                IResource[] resources = ((MergeWizard) getWizard()).getResources();
                if (resources == null)
                    return;
                monitor.beginTask(Messages.MergeWizardBestPracticesPage_0, resources.length);
                for (int i = 0; i < resources.length; i++) {
                    monitor.subTask(resources[i].getName());
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(resources[i]);
                    ISVNClientAdapter svnClient = null;
                    try {
                        svnClient = svnResource.getRepository().getSVNClient();
                        File fileProject = new File(resources[i].getLocation().toString());
                        List incompleteInfoList = new ArrayList();
                        ISVNInfo[] infos = svnClient.getInfo(fileProject, true);
                        for (int j = 0; j < infos.length; j++) {
                            if (infos[j].getDepth() != Depth.infinity && infos[j].getDepth() != Depth.unknown) {
                                incompleteWorkingCopy = true;
                                incompleteInfoList.add(infos[j].getUrl().toString());
                            }
                        }
                        File file = new File(resources[i].getLocation().toString());
                        ISVNStatus status = svnClient.getSingleStatus(file);
                        highestRevision = status.getRevision().getNumber();
                        ISVNStatus[] statuses = svnClient.getStatus(file, true, true, false, true);
                        for (int j = 0; j < statuses.length; j++) {
                            if (statuses[j].getUrl() != null && incompleteInfoList.contains(statuses[j].getUrl().toString())) {
                                incompleteList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (statuses[j].getTextStatus().equals(SVNStatusKind.MODIFIED) | statuses[j].getPropStatus().equals(SVNStatusKind.MODIFIED)) {
                                localMods = true;
                                localModsList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (statuses[j].isSwitched()) {
                                switchedChildren = true;
                                switchedChildrenList.add(SVNWorkspaceRoot.getResourceFor(resources[i], statuses[j]));
                            }
                            if (!statuses[j].getTextStatus().equals(SVNStatusKind.EXTERNAL) && !statuses[j].isFileExternal() && statuses[j].getRevision() != null) {
                                if (!statuses[j].getRevision().equals(status.getRevision())) {
                                    mixedRevisions = true;
                                    if (!mixedRevisionsList.contains(resources[i]))
                                        mixedRevisionsList.add(resources[i]);
                                    if (statuses[j].getRevision().getNumber() > highestRevision) {
                                        highestRevision = statuses[j].getRevision().getNumber();
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        Activator.handleError(e);
                    } finally {
                        svnResource.getRepository().returnSVNClient(svnClient);
                    }
                    monitor.worked(1);
                }
                monitor.done();
            }
        });
    } catch (Exception e) {
        Activator.handleError(e);
    }
    if (refreshPage)
        refreshPage(true, false);
    if (localMods || switchedChildren || mixedRevisions || incompleteWorkingCopy) {
        setMessage(Messages.MergeWizardBestPracticesPage_notReady);
        setPageComplete(false);
    } else {
        setMessage(Messages.MergeWizardBestPracticesPage_ready);
        setPageComplete(true);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ISVNStatus(org.tigris.subversion.svnclientadapter.ISVNStatus) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) File(java.io.File) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Example 13 with ISVNStatus

use of org.tigris.subversion.svnclientadapter.ISVNStatus 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)

Example 14 with ISVNStatus

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

the class GenerateDiffFileAction method getModifiedResources.

protected IResource[] getModifiedResources(IResource[] resources, IProgressMonitor iProgressMonitor) throws SVNException {
    final List modified = new ArrayList();
    List unversionedFolders = new ArrayList();
    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;
        }
        // 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.isReadyForCommit(statuses[j]) || SVNStatusUtils.isMissing(statuses[j])) {
                IResource currentResource = SVNWorkspaceRoot.getResourceFor(resource, statuses[j]);
                if (currentResource != null) {
                    ISVNLocalResource localResource = SVNWorkspaceRoot.getSVNResourceFor(currentResource);
                    if (!localResource.isIgnored()) {
                        if (!SVNStatusUtils.isManaged(statuses[j])) {
                            if (!isSymLink(currentResource)) {
                                if (currentResource.getType() != IResource.FILE)
                                    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());
                                    if (addToUnadded(currentResource))
                                        unaddedList.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());
                        }
                    }
                }
            }
        }
    }
    // get unadded resources and add them to the list.
    IResource[] unaddedResources = getUnaddedResources(unversionedFolders, iProgressMonitor);
    for (int i = 0; i < unaddedResources.length; i++) {
        if (!modified.contains(unaddedResources[i])) {
            if (unaddedResources[i].getType() == IResource.FILE) {
                modified.add(unaddedResources[i]);
                statusMap.put(unaddedResources[i], SVNStatusKind.UNVERSIONED);
            }
            if (addToUnadded(unaddedResources[i]))
                unaddedList.add(unaddedResources[i]);
        }
    }
    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) IContainer(org.eclipse.core.resources.IContainer) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) IResource(org.eclipse.core.resources.IResource)

Aggregations

ISVNStatus (org.tigris.subversion.svnclientadapter.ISVNStatus)14 ArrayList (java.util.ArrayList)8 IResource (org.eclipse.core.resources.IResource)8 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)7 List (java.util.List)6 IContainer (org.eclipse.core.resources.IContainer)5 GetStatusCommand (org.tigris.subversion.subclipse.core.commands.GetStatusCommand)4 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)4 File (java.io.File)3 SVNClientException (org.tigris.subversion.svnclientadapter.SVNClientException)3 Iterator (java.util.Iterator)2 IFile (org.eclipse.core.resources.IFile)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 IProject (org.eclipse.core.resources.IProject)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1