SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"{0} seems to be not a disjoint wc since it has no parent", nestedWC);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNWCAccess parentWCAccess = createWCAccess();
SVNWCAccess nestedWCAccess = createWCAccess();
try {
SVNAdminArea parentArea = parentWCAccess.open(nestedWCParent, true, 0);
SVNEntry srcEntryInParent = parentWCAccess.getEntry(nestedWC, false);
if (srcEntryInParent != null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_EXISTS,
"Entry ''{0}'' already exists in parent directory", nestedWC.getName());
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNAdminArea nestedArea = nestedWCAccess.open(nestedWC, false, SVNWCAccess.INFINITE_DEPTH);
SVNEntry nestedWCThisEntry = nestedWCAccess.getVersionedEntry(nestedWC, false);
SVNEntry parentThisEntry = parentWCAccess.getVersionedEntry(nestedWCParent, false);
// uuids may be identical while it might be absolutely independent repositories.
// subversion uses repos roots comparison for local copies, and uuids comparison for
// operations involving ra access. so, I believe we should act similarly here.
if (nestedWCThisEntry.getRepositoryRoot() != null && parentThisEntry.getRepositoryRoot() != null &&
!nestedWCThisEntry.getRepositoryRoot().equals(parentThisEntry.getRepositoryRoot())) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_INVALID_SCHEDULE,
"Cannot copy to ''{0}'', as it is not from repository ''{1}''; it is from ''{2}''",
new Object[] { nestedWCParent, nestedWCThisEntry.getRepositoryRootURL(),
parentThisEntry.getRepositoryRootURL() });
SVNErrorManager.error(err, SVNLogType.WC);
}
if (parentThisEntry.isScheduledForDeletion()) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_INVALID_SCHEDULE,
"Cannot copy to ''{0}'', as it is scheduled for deletion", nestedWCParent);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (nestedWCThisEntry.isScheduledForDeletion()) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_INVALID_SCHEDULE,
"Cannot copy ''{0}'', as it is scheduled for deletion", nestedWC);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNURL nestedWCReposRoot = getReposRoot(nestedWC, null, SVNRevision.WORKING, nestedArea,
nestedWCAccess);
String nestedWCPath = getPathRelativeToRoot(nestedWC, null, nestedWCReposRoot, nestedWCAccess, null);
SVNURL parentReposRoot = getReposRoot(nestedWCParent, null, SVNRevision.WORKING, parentArea,
parentWCAccess);
String parentPath = getPathRelativeToRoot(nestedWCParent, null, parentReposRoot, parentWCAccess, null);
if (SVNPathUtil.isAncestor(nestedWCPath, parentPath)) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"Cannot copy path ''{0}'' into its own child ''{1}",
new Object[] { nestedWCPath, parentPath });
SVNErrorManager.error(err, SVNLogType.WC);
}
if ((nestedWCThisEntry.isScheduledForAddition() && !nestedWCThisEntry.isCopied()) ||
nestedWCThisEntry.getURL() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_EXISTS,
"Cannot copy or move ''{0}'': it is not in repository yet; " +
"try committing first", nestedWC);
SVNErrorManager.error(err, SVNLogType.WC);
}
copyDisjointDir(nestedWC, parentWCAccess, nestedWCParent);
parentWCAccess.probeTry(nestedWC, true, SVNWCAccess.INFINITE_DEPTH);
} finally {
parentWCAccess.close();
nestedWCAccess.close();
sleepForTimeStamp();
}
}