org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "LBL_DiffRevisions.status.added=Added",
    "LBL_DiffRevisions.status.removed=Removed",
    "LBL_DiffRevisions.status.modified=Modified",
    "LBL_DiffRevisions.status.uptodate=Normal"
})
private static String toStatusText (SVNDiffSummary.SVNDiffKind diffKind) {
    if (diffKind == SVNDiffSummary.SVNDiffKind.DELETED) {
        return Bundle.LBL_DiffRevisions_status_removed();
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.ADDED) {
        return Bundle.LBL_DiffRevisions_status_added();
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.MODIFIED) {
        return Bundle.LBL_DiffRevisions_status_modified();
    } else {
        return Bundle.LBL_DiffRevisions_status_uptodate();
    }
}
 
Example #2
Source File: SVNLocalCompareInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
			path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
			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;
}
 
Example #3
Source File: SVNFolderCompareEditorInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
			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;
}
 
Example #4
Source File: SVNLocalCompareSummaryInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
			path = path.replaceAll("\\\\", "/"); //$NON-NLS-1$ //$NON-NLS-2$
			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;
}
 
Example #5
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private SVNDiffKind getDiffKind(String changedResource,
		boolean deletedLines, boolean addedLines, boolean contextLines,
		boolean oldRev0, boolean newRev0) {
	SVNDiffKind diffKind;
	if (oldRev0 && newRev0) {
		diffKind = SVNDiffKind.DELETED;
	} else if (addedLines && !deletedLines && !contextLines)
		diffKind = SVNDiffKind.ADDED;
	else if ((!deletedLines && !addedLines) || deletedLines && !addedLines
			&& !contextLines) {
		if (exists(changedResource)) {
			diffKind = SVNDiffKind.DELETED;
		} else {
			diffKind = SVNDiffKind.ADDED;
		}
	} else
		diffKind = SVNDiffKind.MODIFIED;
	return diffKind;
}
 
Example #6
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<SvnDiff> diff(final URL url, long fromRevision, long toRevision) throws SvnClientException {
	final List<SvnDiff> list = new ArrayList<>();
	try {
		final SVNDiffSummary[] diffSummarize = client.diffSummarize(toSVNUrl(url), new Number(fromRevision),
				toSVNUrl(url), new Number(toRevision), Depth.infinity, true);
		for (final SVNDiffSummary svnDiffSummary : diffSummarize) {
			final SvnDiffAction action;
			if (svnDiffSummary.getDiffKind() == SVNDiffKind.ADDED) {
				action = SvnDiffAction.ADDED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.DELETED) {
				action = SvnDiffAction.DELETED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.MODIFIED) {
				action = SvnDiffAction.MODIFIED;
			} else if (svnDiffSummary.getDiffKind() == SVNDiffKind.NORMAL) {
				if (svnDiffSummary.propsChanged()) {
					action = SvnDiffAction.PROPERTY_CHANGED;
				} else {
					throw LogUtil
							.throwing(new SvnClientException("Unknown state of SVNDiffSummary " + svnDiffSummary));
				}
			} else {
				throw LogUtil
						.throwing(new SvnClientException("Unknown SvnDiffAction " + svnDiffSummary.getDiffKind()));
			}
			list.add(new SvnDiff(action, new URL(convertURLToString(url) + '/' + svnDiffSummary.getPath())));
		}
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
	return list;
}
 
Example #7
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Setup createSetup (SVNDiffSummary summary, File file, SVNUrl leftUrl, SVNRevision leftRevision,
        SVNUrl rightUrl, String rightRevision) {
    FileInformation fi = null;
    Setup localSetup = wcSetups.get(file);
    boolean deleted = summary.getDiffKind() == SVNDiffKind.DELETED;
    boolean added = summary.getDiffKind() == SVNDiffKind.ADDED;
    if (localSetup != null) {
        // local file, diffing WC
        fi = cache.getStatus(file);
        if (added && (fi.getStatus() & FileInformation.STATUS_IN_REPOSITORY) == 0) {
            // don't override added status with modified
            fi = null;
        } else {
            deleted = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) != 0;
            added = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_ADDEDLOCALLY
                    | FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) != 0;
        }
    }
    if (fi == null) {
        fi = new RevisionsFileInformation(summary);
    }
    wcSetups.remove(file);
    Setup setup = new Setup(file, repositoryUrl,
            leftUrl, added ? null : leftRevision.toString(),
            SVNUrlUtils.getRelativePath(repositoryUrl, leftUrl) + "@" + leftRevision,
            rightUrl, deleted ? null : rightRevision,
            Setup.REVISION_CURRENT.equals(rightRevision)
            ? file.getName() + "@" + rightRevision
            : SVNUrlUtils.getRelativePath(repositoryUrl, rightUrl) + "@" + rightRevision,
            fi);
    setup.setNode(new DiffNode(setup, new SvnFileNode(file), FileInformation.STATUS_ALL));
    return setup;
}
 
Example #8
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static int toStatus (SVNDiffSummary.SVNDiffKind diffKind) {
    if (diffKind == SVNDiffSummary.SVNDiffKind.ADDED) {
        return FileInformation.STATUS_VERSIONED_ADDEDLOCALLY;
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.DELETED) {
        return FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY;
    } else if (diffKind == SVNDiffSummary.SVNDiffKind.MODIFIED) {
        return FileInformation.STATUS_VERSIONED_MODIFIEDLOCALLY;
    } else {
        return FileInformation.STATUS_VERSIONED_UPTODATE;
    }
}
 
Example #9
Source File: SVNLocalCompareSummaryInput.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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, statuses[i].getNodeKind().toInt()); //$NON-NLS-1$ //$NON-NLS-2$
				diffSummaryList.add(diffSummary);
			}
		}
	}
	SVNDiffSummary[] diffSummaries = new SVNDiffSummary[diffSummaryList.size()];
	diffSummaryList.toArray(diffSummaries);
	return diffSummaries;
}
 
Example #10
Source File: SummaryEditionNode.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private boolean include(SVNDiffSummary diff) {
	if (diff.getNodeKind() != SVNNodeKind.FILE.toInt() && (diff.getPath() == null || diff.getPath().length() == 0)) return false;
	if (diff.getDiffKind().equals(SVNDiffKind.ADDED) && nodeType == RIGHT) return false;
	if (diff.getDiffKind().equals(SVNDiffKind.DELETED) && nodeType == LEFT) return false;				
	return true;
}