Search in sources :

Example 1 with SVNDiffKind

use of org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind in project subclipse by subclipse.

the class SVNLocalCompareSummaryInput method getDiffSummary.

private SVNDiffSummary[] getDiffSummary(RemoteResourceStatus[] statuses, ISVNLocalResource resource) {
    List diffSummaryList = new ArrayList();
    int rootPathLength = resource.getResource().getLocation().toString().length() + 1;
    for (int i = 0; i < statuses.length; i++) {
        if (statuses[i].getFile() != null && !statuses[i].getNodeKind().equals(SVNNodeKind.DIR)) {
            SVNStatusKind textStatus = statuses[i].getTextStatus();
            boolean propertyChanges = !statuses[i].getPropStatus().equals(SVNStatusKind.NORMAL) && !statuses[i].getPropStatus().equals(SVNStatusKind.NONE);
            boolean localChanges = false;
            if (textStatus.equals(SVNStatusKind.NONE) && propertyChanges && statuses[i].getNodeKind().equals(SVNNodeKind.FILE)) {
                IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(statuses[i].getPath()));
                if (file != null) {
                    ISVNLocalResource svnResource = SVNWorkspaceRoot.getSVNResourceFor(file);
                    try {
                        LocalResourceStatus localStatus = svnResource.getStatus();
                        if (localStatus != null) {
                            localChanges = localStatus.isAdded() || localStatus.isDirty();
                        }
                    } catch (SVNException e) {
                    }
                }
            }
            if (!textStatus.equals(SVNStatusKind.NONE) || !propertyChanges || localChanges) {
                SVNDiffKind diffKind = null;
                if (statuses[i].getTextStatus().equals(SVNStatusKind.ADDED))
                    diffKind = SVNDiffKind.ADDED;
                else if (statuses[i].getTextStatus().equals(SVNStatusKind.DELETED))
                    diffKind = SVNDiffKind.DELETED;
                else
                    diffKind = SVNDiffKind.MODIFIED;
                SVNDiffSummary diffSummary = new SVNDiffSummary(statuses[i].getPath().substring(rootPathLength).replaceAll("\\\\", "/"), diffKind, propertyChanges, // $NON-NLS-1$ //$NON-NLS-2$
                statuses[i].getNodeKind().toInt());
                diffSummaryList.add(diffSummary);
            }
        }
    }
    SVNDiffSummary[] diffSummaries = new SVNDiffSummary[diffSummaryList.size()];
    diffSummaryList.toArray(diffSummaries);
    return diffSummaries;
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) SVNException(org.tigris.subversion.subclipse.core.SVNException) ISVNLocalResource(org.tigris.subversion.subclipse.core.ISVNLocalResource) SVNDiffSummary(org.tigris.subversion.svnclientadapter.SVNDiffSummary) ArrayList(java.util.ArrayList) List(java.util.List) SVNStatusKind(org.tigris.subversion.svnclientadapter.SVNStatusKind) LocalResourceStatus(org.tigris.subversion.subclipse.core.resources.LocalResourceStatus) SVNDiffKind(org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 Path (org.eclipse.core.runtime.Path)1 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)1 SVNException (org.tigris.subversion.subclipse.core.SVNException)1 LocalResourceStatus (org.tigris.subversion.subclipse.core.resources.LocalResourceStatus)1 SVNDiffSummary (org.tigris.subversion.svnclientadapter.SVNDiffSummary)1 SVNDiffKind (org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind)1 SVNStatusKind (org.tigris.subversion.svnclientadapter.SVNStatusKind)1