org.tigris.subversion.svnclientadapter.SVNDiffSummary Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNDiffSummary. 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: 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 #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: 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 #5
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 #6
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void cacheSummaries (SVNDiffSummary[] diffSummaries, SVNUrl leftUrl,
        SVNRevision leftRevision, SVNRevision rightRevision) {
    String revisionString = "@" + leftRevision + ":" + rightRevision;
    Map<String, List<SVNDiffSummary>> sums = new LinkedHashMap<>();
    sums.put("", new ArrayList<SVNDiffSummary>(diffSummaries.length));
    for (SVNDiffSummary s : diffSummaries) {
        String path = s.getPath();
        do {
            List<SVNDiffSummary> list = sums.get(path);
            if (list == null) {
                list = new ArrayList<>();
                sums.put(path, list);
            }
            String suffix = s.getPath().substring(path.length());
            if (suffix.startsWith("/")) {
                suffix = suffix.substring(1);
            }
            list.add(new SVNDiffSummary(suffix, s.getDiffKind(), s.propsChanged(), s.getNodeKind()));
            int index = path.lastIndexOf("/");
            if (index > -1) {
                path = path.substring(0, index);
            } else if (!path.isEmpty()) {
                path = "";
            } else {
                path = null;
            }
        } while (path != null);
    }
    for (Map.Entry<String, List<SVNDiffSummary>> e : sums.entrySet()) {
        SVNDiffSummary[] summaryArray = e.getValue().toArray(new SVNDiffSummary[e.getValue().size()]);
        String key;
        if (e.getKey().isEmpty()) {
            key = leftUrl.toString();
        } else {
            key = leftUrl.toString() + "/" + e.getKey();
        }
        key += revisionString;
        diffSummaryCache.put(key, summaryArray);
    }
}
 
Example #7
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private SVNDiffSummary[] getCachedSummaries (SVNUrl url, SVNRevision leftRevision, SVNRevision rightRevision) {
    String revisionString = "@" + leftRevision + ":" + rightRevision;
    boolean direct = true;
    while (url != null) {
        SVNDiffSummary[] sums = diffSummaryCache.get(url.toString() + revisionString);
        if (sums != null) {
            return direct ? sums : new SVNDiffSummary[0];
        }
        direct = false;
        url = url.getParent();
    }
    return null;
}
 
Example #8
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public SVNDiffSummary[] diffSummarize(File path, SVNRevision pegRevision,
		SVNRevision startRevision, SVNRevision endRevision, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	String target = fileToSVNPath(path, false);
	return this.diffSummarize(target, pegRevision, startRevision,
			endRevision, depth, ignoreAncestry);
}
 
Example #9
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 #10
Source File: JhlConverter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public static SVNDiffSummary.SVNDiffKind convert(DiffSummary.DiffKind d) {
	if (d == DiffSummary.DiffKind.added) {
		return SVNDiffSummary.SVNDiffKind.ADDED;
	} else if (d == DiffSummary.DiffKind.modified) {
		return SVNDiffSummary.SVNDiffKind.MODIFIED;
	} else if (d == DiffSummary.DiffKind.deleted) {
		return SVNDiffSummary.SVNDiffKind.DELETED;
	} else {
		return SVNDiffSummary.SVNDiffKind.NORMAL;
	}
}
 
Example #11
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private SVNDiffSummary[] diffSummarize(String target,
		SVNRevision pegRevision, SVNRevision startRevision,
		SVNRevision endRevision, int depth, boolean ignoreAncestry)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		if (pegRevision == null)
			pegRevision = SVNRevision.HEAD;
		if (startRevision == null)
			startRevision = SVNRevision.HEAD;
		if (endRevision == null)
			endRevision = SVNRevision.HEAD;

		String commandLine = "diff --summarize";
		Depth d = JhlConverter.depth(depth);
		commandLine += depthCommandLine(d);
		if (ignoreAncestry)
			commandLine += " --ignoreAncestry";
		commandLine += " -r " + startRevision + ":" + endRevision + " "
				+ target;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver();
		svnClient.diffSummarize(target, JhlConverter.convert(pegRevision),
				JhlConverter.convert(startRevision),
				JhlConverter.convert(endRevision), d, null, ignoreAncestry,
				callback);
		return callback.getDiffSummary();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #12
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private SVNDiffSummary[] diffSummarize(String target1,
		SVNRevision revision1, String target2, SVNRevision revision2,
		int depth, boolean ignoreAncestry) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		if (revision1 == null)
			revision1 = SVNRevision.HEAD;
		if (revision2 == null)
			revision2 = SVNRevision.HEAD;

		String commandLine = "diff --summarize";
		Depth d = JhlConverter.depth(depth);
		commandLine += depthCommandLine(d);
		if (ignoreAncestry)
			commandLine += " --ignoreAncestry";
		commandLine += " " + target1 + "@" + revision1 + " " + target2
				+ "@" + revision2;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver();
		svnClient.diffSummarize(target1, JhlConverter.convert(revision1),
				target2, JhlConverter.convert(revision2), d, null,
				ignoreAncestry, callback);
		return callback.getDiffSummary();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #13
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 #14
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
@NbBundle.Messages({
    "MSG_Error.diffSummaryWithCLI.CLIforced=Diffing between revision trees is not supported with commandline client.",
    "MSG_Error.diffSummaryWithCLI=Diffing between revision trees is not supported with commandline client.\nPlease switch to SVNKit or JavaHL."
})
public SVNDiffSummary[] diffSummarize(SVNUrl arg0, SVNRevision arg1, SVNUrl arg2, SVNRevision arg3, int arg4, boolean arg5) throws SVNClientException {
    throw new SVNClientException(SvnModuleConfig.getDefault().isForcedCommandlineClient()
            ? Bundle.MSG_Error_diffSummaryWithCLI_CLIforced()
            : Bundle.MSG_Error_diffSummaryWithCLI());
}
 
Example #15
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 #16
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNDiffSummary[] diffSummarize(File target1, SVNRevision revision1,
		SVNUrl target2, SVNRevision revision2, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	return diffSummarize(fileToSVNPath(target1, false), revision1,
			target2.toString(), revision2, depth, ignoreAncestry);
}
 
Example #17
Source File: SVNLocalResourceSummaryNode.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNLocalResourceSummaryNode(ISVNLocalResource svnResource, SVNDiffSummary[] diffSummary, String rootLocation) {
	super(svnResource.getIResource());
       this.svnResource = svnResource;
       this.diffSummary = diffSummary;
       this.rootLocation = rootLocation;
}
 
Example #18
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNDiffSummary[] diffSummarize(SVNUrl target1,
		SVNRevision revision1, SVNUrl target2, SVNRevision revision2,
		int depth, boolean ignoreAncestry) throws SVNClientException {
	return diffSummarize(target1.toString(), revision1, target2.toString(),
			revision2, depth, ignoreAncestry);
}
 
Example #19
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNDiffSummary[] diffSummarize(File path, SVNUrl toUrl,
		SVNRevision toRevision, boolean recurse) throws SVNClientException {
	return diffSummarize(path.getAbsolutePath(), SVNRevision.WORKING,
			toUrl.toString(), toRevision, Depth.infinity.ordinal(), true);
}
 
Example #20
Source File: JhlConverter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public static SVNDiffSummary convert(DiffSummary d) {
	return new SVNDiffSummary(d.getPath(), JhlConverter.convert(d.getDiffKind()),
			d.propsChanged(), d.getNodeKind().ordinal());
}
 
Example #21
Source File: JhlDiffSummaryReceiver.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNDiffSummary[] getDiffSummary() {
	SVNDiffSummary[] diffSummary = new SVNDiffSummary[summary.size()];
	summary.toArray(diffSummary);
	return diffSummary;
}
 
Example #22
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public SVNDiffSummary[] diffSummarize(SVNUrl url, SVNRevision pegRevision,
		SVNRevision startRevision, SVNRevision endRevision, int depth,
		boolean ignoreAncestry) throws SVNClientException {
	return this.diffSummarize(url.toString(), pegRevision, startRevision,
			endRevision, depth, ignoreAncestry);
}
 
Example #23
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;
}
 
Example #24
Source File: SummaryEditionNode.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void setDiffSummary(SVNDiffSummary[] diffSummary) {
	this.diffSummary = diffSummary;
}
 
Example #25
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public RevisionsFileInformation (SVNDiffSummary item) {
    super(toStatus(item.getDiffKind()), 0, item.getNodeKind() == SVNNodeKind.DIR.toInt());
    this.name = toStatusText(item.getDiffKind());
}
 
Example #26
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public SVNDiffSummary[] diffSummarize(SVNUrl arg0, SVNRevision arg1, SVNRevision arg2, SVNRevision arg3, int arg4, boolean arg5) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}
 
Example #27
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public SVNDiffSummary[] diffSummarize(File file, SVNUrl svnurl, SVNRevision svnr, boolean bln) throws SVNClientException {
    throw new UnsupportedOperationException("Not supported yet.");
}