topDstURL = rootURL;
}
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
SVNEntry entry = wcAccess.getEntry(new File(pair.mySource), false);
pair.mySourceRevisionNumber = entry.getRevision();
String dstRelativePath = SVNPathUtil.getPathAsChild(topDstURL, pair.myDst);
dstRelativePath = SVNEncodingUtil.uriDecode(dstRelativePath);
SVNNodeKind kind = repos.checkPath(dstRelativePath, -1);
if (kind != SVNNodeKind.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_ALREADY_EXISTS,
"Path ''{0}'' already exists", SVNURL.parseURIEncoded(pair.myDst));
SVNErrorManager.error(err, SVNLogType.WC);
}
}
// create commit items list to fetch log messages.
List commitItems = new ArrayList(copyPairs.size());
if (makeParents) {
for (int i = 0; i < newDirs.size(); i++) {
String newDirURL = (String) newDirs.get(i);
SVNURL url = SVNURL.parseURIEncoded(newDirURL);
SVNCommitItem item = new SVNCommitItem(null, url, null, SVNNodeKind.NONE, null, null, true, false, false, false, false, false);
commitItems.add(item);
}
}
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
SVNURL url = SVNURL.parseURIEncoded(pair.myDst);
SVNCommitItem item = new SVNCommitItem(null, url, null, SVNNodeKind.NONE, null, null, true, false, false,
false, false, false);
commitItems.add(item);
}
SVNCommitItem[] commitables = (SVNCommitItem[]) commitItems.toArray(new SVNCommitItem[commitItems.size()]);
message = commitHandler.getCommitMessage(message, commitables);
if (message == null) {
return SVNCommitInfo.NULL;
}
revprops = commitHandler.getRevisionProperties(message, commitables, revprops == null ? new SVNProperties() : revprops);
if (revprops == null) {
return SVNCommitInfo.NULL;
}
Map allCommitables = new TreeMap(SVNCommitUtil.FILE_COMPARATOR);
repos.setLocation(repos.getRepositoryRoot(true), false);
Map pathsToExternalsProps = new SVNHashMap();
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair source = (CopyPair) copyPairs.get(i);
File srcFile = new File(source.mySource);
SVNEntry entry = wcAccess.getVersionedEntry(srcFile, false);
SVNAdminArea dirArea;
if (entry.isDirectory()) {
dirArea = wcAccess.retrieve(srcFile);
} else {
dirArea = wcAccess.retrieve(srcFile.getParentFile());
}
pathsToExternalsProps.clear();
SVNCommitUtil.harvestCommitables(allCommitables, dirArea, srcFile,
null, entry, source.myDst, entry.getURL(), true, false, false, null, SVNDepth.INFINITY,
false, null, commitParameters, pathsToExternalsProps);
SVNCommitItem item = (SVNCommitItem) allCommitables.get(srcFile);
SVNURL srcURL = entry.getSVNURL();
Map mergeInfo = calculateTargetMergeInfo(srcFile, wcAccess, srcURL,
source.mySourceRevisionNumber, repos, false);
Map wcMergeInfo = SVNPropertiesManager.parseMergeInfo(srcFile, entry, false);
if (wcMergeInfo != null && mergeInfo != null) {
mergeInfo = SVNMergeInfoUtil.mergeMergeInfos(mergeInfo, wcMergeInfo);
} else if (mergeInfo == null) {
mergeInfo = wcMergeInfo;
}
if (mergeInfo != null) {
String mergeInfoString = SVNMergeInfoUtil.formatMergeInfoToString(mergeInfo, null);
setCommitItemProperty(item, SVNProperty.MERGE_INFO, SVNPropertyValue.create(mergeInfoString));
}
if (!pathsToExternalsProps.isEmpty()) {
LinkedList newExternals = new LinkedList();
for (Iterator pathsIter = pathsToExternalsProps.keySet().iterator(); pathsIter.hasNext();) {
File localPath = (File) pathsIter.next();
String externalsPropString = (String) pathsToExternalsProps.get(localPath);
SVNExternal[] externals = SVNExternal.parseExternals(localPath.getAbsolutePath(),
externalsPropString);
boolean introduceVirtualExternalChange = false;
newExternals.clear();
for (int k = 0; k < externals.length; k++) {
File externalWC = new File(localPath, externals[k].getPath());
SVNEntry externalEntry = null;
try {
wcAccess.open(externalWC, false, 0);
externalEntry = wcAccess.getVersionedEntry(externalWC, false);
} catch (SVNException svne) {
if (svne instanceof SVNCancelException) {
throw svne;
}
} finally {
wcAccess.closeAdminArea(externalWC);
}
SVNRevision externalsWCRevision = SVNRevision.UNDEFINED;
if (externalEntry != null) {
externalsWCRevision = SVNRevision.create(externalEntry.getRevision());
}
SVNEntry ownerEntry = wcAccess.getEntry(localPath, false);
SVNURL ownerURL = null;
if (ownerEntry != null) {
ownerURL = ownerEntry.getSVNURL();
}
if (ownerURL == null) {
// there is no entry for the directory that has external
// property or no url in it?
continue;