if (dstEntry.getRepositoryRoot() == null || dstEntry.getURL() == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_COPYFROM_PATH_NOT_FOUND,
"Destination directory of add-with-history is missing a URL");
SVNErrorManager.error(err, SVNLogType.WC);
}
dstDir = new Resource(SVNPathUtil.validateFilePath(dstDir.getAbsolutePath())).getAbsoluteFile();
String dstReposPath = SVNPathUtil.getPathAsChild(dstEntry.getRepositoryRootURL().toDecodedString(),
dstEntry.getSVNURL().toDecodedString());
if (dstReposPath == null) {
if (dstEntry.getURL().equals(dstEntry.getRepositoryRoot())) {
dstReposPath = "";
} else {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_COPYFROM_PATH_NOT_FOUND,
"Destination URLs are broken");
SVNErrorManager.error(err, SVNLogType.WC);
}
}
dstReposPath = "/" + dstReposPath;
dstReposPath = SVNPathUtil.canonicalizePath(dstReposPath);
String copyFromParent = SVNPathUtil.removeTail(copyFromPath);
String ancestorPath = SVNPathUtil.getCommonPathAncestor(dstReposPath, copyFromParent);
if ("".equals(ancestorPath)) {
return null;
}
int levelsUP = SVNPathUtil.getSegmentsCount(dstReposPath) - SVNPathUtil.getSegmentsCount(ancestorPath);
File currentWD = dstDir;
for (int i = 0; i < levelsUP && currentWD != null; i++) {
currentWD = currentWD.getParentFile();
}
if (currentWD == null) {
return null;
}
SVNFileType kind = SVNFileType.getType(currentWD);
if (kind != SVNFileType.DIRECTORY) {
return null;
}
SVNWCAccess ancestorAccess = SVNWCAccess.newInstance(null);
SVNAdminArea ancestorArea = null;
try {
ancestorArea = ancestorAccess.open(currentWD, false, 0);
} catch (SVNException svne) {
if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.WC_NOT_DIRECTORY) {
ancestorAccess.close();
return null;
}
throw svne;
}
SVNEntry ancestorEntry = ancestorArea.getEntry(ancestorArea.getThisDirName(), false);
if (dstEntry.getUUID() != null && ancestorEntry.getUUID() != null &&
!dstEntry.getUUID().equals(ancestorEntry.getUUID())) {
ancestorAccess.close();
return null;
}
SVNURL ancestorURL = dstEntry.getRepositoryRootURL().appendPath(ancestorPath, false);
if (!ancestorURL.equals(ancestorEntry.getSVNURL())) {
ancestorAccess.close();
return null;
}
String extraComponents = SVNPathUtil.getPathAsChild(ancestorPath, copyFromPath);
currentWD = new Resource(currentWD, extraComponents);
File currentWDParent = currentWD.getParentFile();
kind = SVNFileType.getType(currentWD);
if (kind != SVNFileType.FILE) {
ancestorAccess.close();