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;
}
SVNRevision[] revs = externalsHandler.handleExternal(
externalWC,
externals[k].resolveURL(repos.getRepositoryRoot(true), ownerURL),
externals[k].getRevision(),
externals[k].getPegRevision(),
externals[k].getRawValue(),
externalsWCRevision);
if (revs != null && revs[0].equals(externals[k].getRevision())) {
newExternals.add(externals[k].getRawValue());
} else if (revs != null) {
SVNExternal newExternal = new SVNExternal(externals[k].getPath(),
externals[k].getUnresolvedUrl(), revs[1],
revs[0], true, externals[k].isPegRevisionExplicit(),
externals[k].isNewFormat());
newExternals.add(newExternal.toString());
if (!introduceVirtualExternalChange) {
introduceVirtualExternalChange = true;
}
}
}
if (introduceVirtualExternalChange) {
String newExternalsProp = "";
for (Iterator externalsIter = newExternals.iterator(); externalsIter.hasNext();) {
String external = (String) externalsIter.next();
newExternalsProp += external + '\n';
}
SVNCommitItem itemWithExternalsChanges = (SVNCommitItem) allCommitables.get(localPath);
if (itemWithExternalsChanges != null) {
setCommitItemProperty(itemWithExternalsChanges, SVNProperty.EXTERNALS, SVNPropertyValue.create(newExternalsProp));
} else {
SVNAdminArea childArea = wcAccess.retrieve(localPath);
String relativePath = childArea.getRelativePath(dirArea);
String itemURL = SVNPathUtil.append(source.myDst,
SVNEncodingUtil.uriEncode(relativePath));
itemWithExternalsChanges = new SVNCommitItem(localPath,
SVNURL.parseURIEncoded(itemURL), null, SVNNodeKind.DIR, null, null,
false, false, true, false, false, false);
setCommitItemProperty(itemWithExternalsChanges, SVNProperty.EXTERNALS, SVNPropertyValue.create(newExternalsProp));
allCommitables.put(localPath, itemWithExternalsChanges);
}
}
}
}
}
commitItems = new ArrayList(allCommitables.values());
// add parents to commits hash?
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);
}
}
commitables = (SVNCommitItem[]) commitItems.toArray(new SVNCommitItem[commitItems.size()]);
for (int i = 0; i < commitables.length; i++) {