public static void crop(SVNAdminAreaInfo info, SVNDepth depth) throws SVNException {
if (depth == SVNDepth.INFINITY) {
return;
}
if (!(depth.compareTo(SVNDepth.EXCLUDE) >= 0 && depth.compareTo(SVNDepth.INFINITY) < 0)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Can only crop a working copy with a restrictive depth");
SVNErrorManager.error(err, SVNLogType.WC);
}
// get target entry
SVNWCAccess wcAccess = info.getWCAccess();
File fullPath = info.getAnchor().getRoot();
if (!"".equals(info.getTargetName())) {
fullPath = new File(fullPath, info.getTargetName());
}
SVNEntry targetEntry = wcAccess.getEntry(fullPath, false);
if (targetEntry == null || !targetEntry.isDirectory()) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Can only crop directories");
SVNErrorManager.error(err, SVNLogType.WC);
}
if (targetEntry.isScheduledForDeletion()) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot crop ''{0}'': it is going to be removed from repository." +
" Try commit instead", fullPath);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (depth == SVNDepth.EXCLUDE) {
if (fullPath.getParentFile() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot exclude root directory");
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNAdminArea parentDir = wcAccess.getAdminArea(fullPath.getParentFile());
SVNEntry parentEntry = null;
if (parentDir == null) {
try {
parentDir = wcAccess.probeOpen(fullPath.getParentFile(), false, 0);
} catch (SVNException e) {
}
}
if (parentDir != null) {
parentEntry = wcAccess.getEntry(fullPath.getParentFile(), false);
}
if (parentEntry != null) {
SVNURL expectedURL = parentEntry.getSVNURL().appendPath(fullPath.getName(), false);
if (!expectedURL.equals(targetEntry.getSVNURL())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot crop ''{0}'': it is a switched path", fullPath);
SVNErrorManager.error(err, SVNLogType.WC);
}
}
boolean inRepos = !((targetEntry.isScheduledForAddition() || targetEntry.isScheduledForReplacement()) && !targetEntry.isCopied());
if (parentEntry != null && inRepos && parentEntry.getDepth().compareTo(SVNDepth.FILES) > 0) {