}
throw originalError;
}
public void addDir(String path, String copyFromPath, long copyFromRevision) throws SVNException {
SVNAdminArea parentArea = myCurrentDirectory.getAdminArea();
SVNDirectoryInfo parentDirectory = myCurrentDirectory;
myCurrentDirectory = createDirectoryInfo(myCurrentDirectory, path, true);
myCurrentDirectory.myPreviousRevision = -1;
if (path.equals(myTarget)) {
myCurrentDirectory.myAmbientDepth = myRequestedDepth == SVNDepth.UNKNOWN ? SVNDepth.INFINITY : myRequestedDepth;
} else if (myRequestedDepth == SVNDepth.IMMEDIATES || (myRequestedDepth == SVNDepth.UNKNOWN &&
parentDirectory.myAmbientDepth == SVNDepth.IMMEDIATES)) {
myCurrentDirectory.myAmbientDepth = SVNDepth.EMPTY;
} else {
myCurrentDirectory.myAmbientDepth = SVNDepth.INFINITY;
}
parentDirectory.flushLog();
checkIfPathIsUnderRoot(path);
String name = SVNPathUtil.tail(path);
File childDir = parentArea.getFile(name);
SVNFileType kind = SVNFileType.getType(childDir);
if (kind == SVNFileType.FILE || kind == SVNFileType.UNKNOWN) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"Failed to add directory ''{0}'': a non-directory object of the same name already exists",
path);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (kind == SVNFileType.DIRECTORY) {
SVNAdminArea adminArea = null;
try {
adminArea = SVNWCAccess.newInstance(null).open(childDir, false, 0);
} catch (SVNException svne) {
if (svne.getErrorMessage().getErrorCode() != SVNErrorCode.WC_NOT_DIRECTORY) {
throw svne;
}
if (myIsUnversionedObstructionsAllowed) {
myCurrentDirectory.isExisted = true;
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"Failed to add directory ''{0}'': an unversioned directory of the same name already exists",
myCurrentDirectory.getPath());
SVNErrorManager.error(err, SVNLogType.WC);
}
}
if (adminArea != null) {
SVNEntry entry = adminArea.getEntry(adminArea.getThisDirName(), false);
if (entry != null && entry.isScheduledForAddition() && !entry.isCopied()) {
myCurrentDirectory.isAddExisted = true;
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"Failed to add directory ''{0}'': a versioned directory of the same name already exists",
myCurrentDirectory.getPath());
SVNErrorManager.error(err, SVNLogType.WC);
}
}
}
if (SVNFileUtil.getAdminDirectoryName().equals(name)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"Failed to add directory ''{0}'': object of the same name as the administrative directory",
path);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (copyFromPath != null || SVNRevision.isValidRevisionNumber(copyFromRevision)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"Failed to add directory ''{0}'': copyfrom arguments not yet supported", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNEntry entry = parentArea.getEntry(name, false);
Map attributes = new SVNHashMap();
attributes.put(SVNProperty.KIND, SVNProperty.KIND_DIR);
attributes.put(SVNProperty.ABSENT, null);
attributes.put(SVNProperty.DELETED, null);
boolean force = false;
if (myCurrentDirectory.isAddExisted) {
attributes.put(SVNProperty.SCHEDULE, null);
force = true;
}
entry = parentArea.modifyEntry(name, attributes, true, force);
if (myCurrentDirectory.isAddExisted) {
attributes.put(SVNProperty.REVISION, Long.toString(myTargetRevision));
if (mySwitchURL != null) {
attributes.put(SVNProperty.URL, SVNPathUtil.append(mySwitchURL, name));
}
SVNAdminArea adminArea = myCurrentDirectory.getAdminArea();
adminArea.modifyEntry(adminArea.getThisDirName(), attributes, true, true);
}
String rootURL = null;
if (SVNPathUtil.isAncestor(myRootURL, myCurrentDirectory.URL)) {
rootURL = myRootURL;
}
if (myWCAccess.getAdminArea(childDir) != null) {
myWCAccess.closeAdminArea(childDir);
}
if (SVNWCManager.ensureAdminAreaExists(childDir, myCurrentDirectory.URL, rootURL, null,
myTargetRevision, myCurrentDirectory.myAmbientDepth)) {
// hack : remove created lock file.
SVNFileUtil.deleteFile(new File(childDir, SVNFileUtil.getAdminDirectoryName() + "/lock"));
}
SVNAdminArea childArea = myWCAccess.open(childDir, true, 0);
myWCAccess.registerCleanupHandler(childArea, myCurrentDirectory);
if (!myCurrentDirectory.isAddExisted) {
SVNEvent event = SVNEventFactory.createSVNEvent(parentArea.getFile(entry.getName()),
SVNNodeKind.DIR, null, myTargetRevision, myCurrentDirectory.isExisted ?
SVNEventAction.UPDATE_EXISTS : SVNEventAction.UPDATE_ADD, null, null, null);