org.tigris.subversion.svnclientadapter.utils.Depth Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.utils.Depth. 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: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public long[] updateEmpty(List<Path> paths) throws SvnClientException {
	/*
	 * ISVNClientAdapter#update(File[], SVNRevision, int, boolean, boolean, boolean)
	 * does not work as expected
	 */
	long[] result = new long[paths.size()];
	for (int i = 0; i < paths.size(); i++) {
		try {
			/*
			 * setDepth = false : Otherwise the depth is set to the local checked out
			 * repository and files are deleted existing in the directory. We don't want to
			 * modify the checked out hierarchy, only update the file.
			 */
			result[i] = client.update(paths.get(i).toFile(), SVNRevision.HEAD, Depth.empty, /* setDepth */false,
					false, true);
		} catch (SVNClientException e) {
			LogUtil.getLogger().log(Level.WARNING, String.format("Could not update '%s'.", paths.get(i).toFile()),
					e);
		}
	}
	return result;
}
 
Example #2
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void merge(Path path, URL url, long revision, boolean recursivly, boolean recordOnly)
		throws SvnClientException {
	try {
		final SVNRevisionRange[] revisionRange = new SVNRevisionRange[] {
				new SVNRevisionRange(new Number(revision - 1), new Number(revision)) };
		client.merge(toSVNUrl(url), // SVN URL
				SVNRevision.HEAD, // pegRevision
				revisionRange, // revisions to merge (must be in the form N-1:M)
				path.toFile(), // target local path
				false, // force
				recursivly ? Depth.infinity : Depth.empty, // how deep to traverse into subdirectories
				false, // ignoreAncestry
				false, // dryRun
				recordOnly); // recordOnly
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
}
 
Example #3
Source File: RevisionAwareDifferencer.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public RevisionAwareDifferencer(SVNLocalResourceNode left,ResourceEditionNode right, File diffFile, SVNRevision pegRevision) {
	if (diffFile == null) {
		ISVNClientAdapter client = null;
    	try {
			diffSummary = null;

    		client = SVNProviderPlugin.getPlugin().getSVNClientManager().getSVNClient();
    		if (pegRevision == null) {
    			pegRevision = SVNRevision.HEAD;
    		}
    		diffSummary = client.diffSummarize(left.getLocalResource().getUrl(), left.getLocalResource().getRevision(), right.getRemoteResource().getUrl(),
        			right.getRemoteResource().getRevision(), Depth.infinity, true);
       		projectRelativePath = left.getLocalResource().getResource().getProjectRelativePath().toString();
       		if (left.getLocalResource().isFolder() && projectRelativePath.length() > 0) projectRelativePath = projectRelativePath + "/";
    	} catch (Exception e) {
        } finally {
          SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
        }
	} else {
		diffFiles = new File[1];
		diffFiles[0] = diffFile;
	}
}
 
Example #4
Source File: JhlConverter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static org.apache.subversion.javahl.types.Depth depth(int depthValue) {
	switch(depthValue) {
	case Depth.empty:
		return org.apache.subversion.javahl.types.Depth.empty;
	case Depth.files:
		return org.apache.subversion.javahl.types.Depth.files;
	case Depth.immediates:
		return org.apache.subversion.javahl.types.Depth.immediates;
	case Depth.infinity:
		return org.apache.subversion.javahl.types.Depth.infinity;
	case Depth.exclude:
		return org.apache.subversion.javahl.types.Depth.exclude;
	default:
		return org.apache.subversion.javahl.types.Depth.unknown;
	}
	
}
 
Example #5
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 #6
Source File: SvnClientJavaHl.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void checkoutEmpty(Path path, URL url) throws SvnClientException {
	Objects.requireNonNull(url);
	checkPath(path);
	try {
		client.checkout(toSVNUrl(url), path.toFile(), SVNRevision.HEAD, Depth.empty, false, false);
	} catch (MalformedURLException | SVNClientException e) {
		throw new SvnClientException(e);
	}
}