public void doAdd(File path, boolean force, boolean mkdir, boolean climbUnversionedParents,
SVNDepth depth, boolean depthIsSticky, boolean includeIgnored, boolean makeParents) throws SVNException {
depth = depth == null ? SVNDepth.UNKNOWN : depth;
path = path.getAbsoluteFile();
if (!mkdir && makeParents && path.getParentFile() != null) {
SVNWCAccess wcAccess = createWCAccess();
try {
addParentDirectories(wcAccess, path.getParentFile());
} finally {
wcAccess.close();
}
}
SVNFileType kind = SVNFileType.getType(path);
if (force && mkdir && kind == SVNFileType.DIRECTORY) {
// directory is already there.
doAdd(path, force, false, true, SVNDepth.EMPTY, depthIsSticky, true, makeParents);
return;
} else if (mkdir) {
// attempt to create dir
File parent = path;
File firstCreated = path;
while (parent != null && SVNFileType.getType(parent) == SVNFileType.NONE) {
if (!parent.equals(path) && !makeParents) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR,
"Cannot create directoy ''{0}'' with non-existent parents", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
firstCreated = parent;
parent = parent.getParentFile();
}
boolean created = path.mkdirs();
if (!created) {
// delete created dirs.
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR,
"Cannot create new directory ''{0}''", path);
while (parent == null ? path != null : !path.equals(parent)) {
SVNFileUtil.deleteAll(path, true);
path = path.getParentFile();
}
SVNErrorManager.error(err, SVNLogType.WC);
}
try {
doAdd(firstCreated, false, false, climbUnversionedParents, depth, depthIsSticky, true, makeParents);
} catch (SVNException e) {
SVNFileUtil.deleteAll(firstCreated, true);
throw e;
}
return;
}
SVNWCAccess wcAccess = createWCAccess();
try {
SVNAdminArea dir = null;
SVNFileType fileType = SVNFileType.getType(path);
if (fileType == SVNFileType.DIRECTORY) {
dir = wcAccess.open(SVNWCUtil.isVersionedDirectory(path.getParentFile()) ? path.getParentFile() : path, true, 0);
} else {
// files and symlink goes here.
dir = wcAccess.open(path.getParentFile(), true, 0);
}
if (fileType == SVNFileType.DIRECTORY && depth.compareTo(SVNDepth.FILES) >= 0) {
addDirectory(path, dir, force, includeIgnored, depth, depthIsSticky);
} else if (fileType == SVNFileType.FILE || fileType == SVNFileType.SYMLINK) {
addFile(path, fileType, dir);
} else {
SVNWCManager.add(path, dir, null, SVNRevision.UNDEFINED, depthIsSticky ? depth : null);
}
} catch (SVNException e) {
if (!(force && e.getErrorMessage().getErrorCode() == SVNErrorCode.ENTRY_EXISTS)) {
throw e;
}
} finally {
wcAccess.close();
}
}