public static void add(File path, SVNAdminArea parentDir, SVNURL copyFromURL, long copyFromRev, SVNDepth depth) throws SVNException {
SVNWCAccess wcAccess = parentDir.getWCAccess();
SVNFileType fileType = SVNFileType.getType(path);
if (fileType == SVNFileType.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND, "''{0}'' not found", path);
SVNErrorManager.error(err, SVNLogType.WC);
} else if (fileType == SVNFileType.UNKNOWN) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND, "Unsupported node kind for path ''{0}''", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNAdminArea dir;
if (fileType == SVNFileType.SYMLINK) {
dir = wcAccess.probeTry(path.getParentFile(), true, copyFromURL != null ? SVNWCAccess.INFINITE_DEPTH : 0);
} else {
dir = wcAccess.probeTry(path, true, copyFromURL != null ? SVNWCAccess.INFINITE_DEPTH : 0);
}
SVNEntry entry = null;
if (dir != null) {
entry = wcAccess.getEntry(path, true);
}
boolean replace = false;
SVNNodeKind kind = SVNFileType.getNodeKind(fileType);
if (entry != null) {
if ((copyFromURL == null && !entry.isScheduledForDeletion() && !entry.isDeleted()) || entry.getDepth() == SVNDepth.EXCLUDE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_EXISTS, "''{0}'' is already under version control", path);
SVNErrorManager.error(err, SVNLogType.WC);
} else if (entry.getKind() != kind) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_NODE_KIND_CHANGE,
"Can''t replace ''{0}'' with a node of a different type; the deletion must be committed and the parent updated before adding ''{0}''", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
replace = entry.isScheduledForDeletion();
}
SVNEntry parentEntry = wcAccess.getEntry(path.getParentFile(), false);
if (parentEntry == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_NOT_FOUND,
"Can''t find parent directory''s entry while trying to add ''{0}''", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (parentEntry.isScheduledForDeletion()) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_SCHEDULE_CONFLICT,
"Can''t add ''{0}'' to a parent directory scheduled for deletion", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
Map command = new SVNHashMap();
String name = path.getName();
if (copyFromURL != null) {
if (parentEntry.getRepositoryRoot() != null && !SVNPathUtil.isAncestor(parentEntry.getRepositoryRoot(), copyFromURL.toString())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"The URL ''{0}'' has a different repository root than its parent", copyFromURL);
SVNErrorManager.error(err, SVNLogType.WC);
}
command.put(SVNProperty.COPYFROM_URL, copyFromURL.toString());
command.put(SVNProperty.COPYFROM_REVISION, SVNProperty.toString(copyFromRev));