* @since 1.2, SVN 1.5
*/
public long doCheckout(SVNURL url, File dstPath, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth,
boolean allowUnversionedObstructions) throws SVNException {
if (dstPath == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.BAD_FILENAME, "Checkout destination path can not be NULL");
SVNErrorManager.error(err, SVNLogType.WC);
}
pegRevision = pegRevision == null ? SVNRevision.UNDEFINED : pegRevision;
if (!revision.isValid() && pegRevision.isValid()) {
revision = pegRevision;
}
if (!revision.isValid()) {
revision = SVNRevision.HEAD;
}
SVNRepository repos = createRepository(url, null, null, pegRevision, revision, null);
url = repos.getLocation();
long revNumber = getRevisionNumber(revision, repos, null);
SVNNodeKind targetNodeKind = repos.checkPath("", revNumber);
if (targetNodeKind == SVNNodeKind.FILE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "URL ''{0}'' refers to a file, not a directory", url);
SVNErrorManager.error(err, SVNLogType.WC);
} else if (targetNodeKind == SVNNodeKind.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_ILLEGAL_URL, "URL ''{0}'' doesn''t exist", url);
SVNErrorManager.error(err, SVNLogType.WC);
}
String uuid = repos.getRepositoryUUID(true);
SVNURL repositoryRoot = repos.getRepositoryRoot(true);
long result = -1;
depth = depth == null ? SVNDepth.UNKNOWN : depth;
SVNWCAccess wcAccess = createWCAccess();
SVNFileType kind = SVNFileType.getType(dstPath);
if (kind == SVNFileType.NONE) {
depth = depth == SVNDepth.UNKNOWN ? SVNDepth.INFINITY : depth;
SVNAdminAreaFactory.createVersionedDirectory(dstPath, url, repositoryRoot, uuid, revNumber, depth);
result = update(dstPath, revision, depth, allowUnversionedObstructions, true, false);
} else if (kind == SVNFileType.DIRECTORY) {
int formatVersion = SVNAdminAreaFactory.checkWC(dstPath, true);
if (formatVersion != 0) {
SVNAdminArea adminArea = wcAccess.open(dstPath, false, 0);
SVNEntry rootEntry = adminArea.getEntry(adminArea.getThisDirName(), false);
wcAccess.closeAdminArea(dstPath);
if (rootEntry.getSVNURL() != null && url.equals(rootEntry.getSVNURL())) {
result = update(dstPath, revision, depth, allowUnversionedObstructions, true, false);
} else {
String message = "''{0}'' is already a working copy for a different URL";
if (rootEntry.isIncomplete()) {
message += "; perform update to complete it";
}
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, message, dstPath);
SVNErrorManager.error(err, SVNLogType.WC);
}
} else {
depth = depth == SVNDepth.UNKNOWN ? SVNDepth.INFINITY : depth;
SVNAdminAreaFactory.createVersionedDirectory(dstPath, url, repositoryRoot, uuid, revNumber, depth);
result = update(dstPath, revision, depth, allowUnversionedObstructions, true, false);
}
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_NODE_KIND_CHANGE, "''{0}'' already exists and is not a directory", dstPath);
SVNErrorManager.error(err, SVNLogType.WC);
}
return result;
}