Search in sources :

Example 6 with SVNDiffSummary

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

Example 7 with SVNDiffSummary

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

the class SVNLocalCompareSummaryInput method getDiffSummaryWithSubfolders.

private SVNDiffSummary[] getDiffSummaryWithSubfolders(SVNDiffSummary[] diffSummary) {
    ArrayList paths = new ArrayList();
    ArrayList diffs = new ArrayList();
    for (int i = 0; i < diffSummary.length; i++) {
        paths.add(diffSummary[i].getPath());
        diffs.add(diffSummary[i]);
    }
    for (int i = 0; i < diffSummary.length; i++) {
        File file = new File(diffSummary[i].getPath());
        while (file.getParentFile() != null) {
            file = file.getParentFile();
            String path = file.getPath();
            // $NON-NLS-1$ //$NON-NLS-2$
            path = path.replaceAll("\\\\", "/");
            if (!paths.contains(path)) {
                paths.add(path);
                SVNDiffSummary folder = new SVNDiffSummary(path, SVNDiffKind.NORMAL, false, SVNNodeKind.DIR.toInt());
                diffs.add(folder);
            }
        }
    }
    diffSummary = new SVNDiffSummary[diffs.size()];
    diffs.toArray(diffSummary);
    return diffSummary;
}
Also used : SVNDiffSummary(org.tigris.subversion.svnclientadapter.SVNDiffSummary) ArrayList(java.util.ArrayList) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

SVNDiffSummary (org.tigris.subversion.svnclientadapter.SVNDiffSummary)7 ArrayList (java.util.ArrayList)6 File (java.io.File)5 ISVNLocalResource (org.tigris.subversion.subclipse.core.ISVNLocalResource)4 DiffNode (org.eclipse.compare.structuremergeviewer.DiffNode)3 IFile (org.eclipse.core.resources.IFile)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)3 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)3 SVNException (org.tigris.subversion.subclipse.core.SVNException)3 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)3 ITypedElement (org.eclipse.compare.ITypedElement)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 ISVNRemoteFolder (org.tigris.subversion.subclipse.core.ISVNRemoteFolder)2 IOException (java.io.IOException)1 List (java.util.List)1 ICompareInput (org.eclipse.compare.structuremergeviewer.ICompareInput)1 IDiffElement (org.eclipse.compare.structuremergeviewer.IDiffElement)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1