}
File victim = alreadyInTreeConflict(fullPath);
if (victim != null) {
addSkippedTree(fullPath);
SVNEvent event = SVNEventFactory.createSVNEvent(fullPath, SVNNodeKind.DIR, null, myTargetRevision, SVNEventAction.SKIP, SVNEventAction.UPDATE_ADD, null, null);
myWCAccess.handleEvent(event);
}
SVNFileType kind = SVNFileType.getType(fullPath);
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(fullPath, 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) {
try {
SVNEntry entry = adminArea.getEntry(adminArea.getThisDirName(), false);
SVNEntry parentEntry = parentArea.getEntry(parentArea.getThisDirName(), false);
SVNEntry entryInParent = (SVNEntry) parentArea.getEntries().get(name);
if (entry != null && parentEntry != null && entry.getUUID() != null && parentEntry.getUUID() != null &&
!entry.getUUID().equals(parentEntry.getUUID())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"UUID mismatch: existing directory ''{0}'' was checked out from a different repository",
myCurrentDirectory.getPath());
SVNErrorManager.error(err, SVNLogType.WC);
}
if (entry != null && mySwitchURL == null && myCurrentDirectory.URL != null && !myCurrentDirectory.URL.equals(entry.getURL())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE,
"URL ''{0}'' of existing directory ''{1}'' does not match expected URL ''{2}''",
new Object[] {entry.getURL(), myCurrentDirectory.getPath(), myCurrentDirectory.URL});
SVNErrorManager.error(err, SVNLogType.WC);
}
if (entryInParent == null) {
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 (entry != null && (entry.isScheduledForAddition() || entry.isScheduledForReplacement()) && !entry.isCopied()) {
myCurrentDirectory.isAddExisted = true;
} else {
SVNURL theirURL = SVNURL.parseURIEncoded(myCurrentDirectory.URL);
SVNTreeConflictDescription treeConflict = checkTreeConflict(fullPath, entry, parentArea, parentDirectory.getLog(), SVNConflictAction.ADD, SVNNodeKind.DIR, theirURL);
try {
parentDirectory.flushLog();
} catch (SVNException svne) {
SVNErrorMessage err = svne.getErrorMessage().wrap("Error writing log file for ''{0}''", parentDirectory.getPath());
SVNErrorManager.error(err, svne, SVNLogType.WC);
}
if (treeConflict != null) {
addSkippedTree(fullPath);
SVNEvent event = SVNEventFactory.createSVNEvent(fullPath, SVNNodeKind.DIR, null, myTargetRevision, SVNEventAction.TREE_CONFLICT, SVNEventAction.UPDATE_ADD, null, null);
if (entry != null) {
event.setPreviousRevision(entry.getRevision());
event.setPreviousURL(entry.getSVNURL());
}
myWCAccess.handleEvent(event);
return;
}
}
} finally {
adminArea.getWCAccess().close();
}
}
}
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 (myRootURL != null && SVNPathUtil.isAncestor(myRootURL, myCurrentDirectory.URL)) {
rootURL = myRootURL;
}
SVNWCManager.ensureAdminAreaExists(fullPath, myCurrentDirectory.URL, rootURL, null, myTargetRevision, myCurrentDirectory.myAmbientDepth);
SVNAdminArea childArea = null;
if (!myAdminInfo.getAnchor().getRoot().equals(fullPath)) {
ISVNEventHandler eventHandler = myWCAccess.getEventHandler();
try {
myWCAccess.setEventHandler(null);
childArea = myWCAccess.open(fullPath, true, 0);
} catch(SVNException e) {
if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LOCKED) {
childArea = myWCAccess.retrieve(fullPath);
} else {
throw e;
}
} finally {
myWCAccess.setEventHandler(eventHandler);
}
}
if (isLocallyDeleted) {
attributes.clear();
attributes.put(SVNProperty.SCHEDULE, SVNProperty.SCHEDULE_DELETE);
parentArea.modifyEntry(name, attributes, true, false);
childArea = myWCAccess.retrieve(fullPath);
childArea.modifyEntry(childArea.getThisDirName(), attributes, true, false);
}
try {
childArea = myWCAccess.open(fullPath, true, 0);
} catch (SVNException e) {
if (e.getErrorMessage().getErrorCode() == SVNErrorCode.WC_LOCKED) {
childArea = myWCAccess.retrieve(fullPath);
} else {
throw e;
}
}
if (childArea != null) {
myWCAccess.registerCleanupHandler(childArea, myCurrentDirectory);
}
if (!myCurrentDirectory.isAddExisted && !isLocallyDeleted) {
SVNEvent event = SVNEventFactory.createSVNEvent(parentArea.getFile(entry.getName()),
SVNNodeKind.DIR, null, myTargetRevision, myCurrentDirectory.isExisted ?
SVNEventAction.UPDATE_EXISTS : SVNEventAction.UPDATE_ADD, null, null, null);
event.setPreviousRevision(myCurrentDirectory.myPreviousRevision);
event.setPreviousURL(entry.getSVNURL());
event.setURL(myCurrentDirectory.URL != null ? SVNURL.parseURIEncoded(myCurrentDirectory.URL) : null);
myWCAccess.handleEvent(event);
}
}