return (SVNCopySource[]) expanded.toArray(new SVNCopySource[expanded.size()]);
}
private SVNCommitInfo copyReposToRepos(List copyPairs, boolean makeParents, boolean isMove, String message, SVNProperties revprops, ISVNCommitHandler commitHandler) throws SVNException {
List pathInfos = new ArrayList();
Map pathsMap = new SVNHashMap();
for (int i = 0; i < copyPairs.size(); i++) {
CopyPathInfo info = new CopyPathInfo();
pathInfos.add(info);
}
String topURL = ((CopyPair) copyPairs.get(0)).mySource;
String topDstURL = ((CopyPair) copyPairs.get(0)).myDst;
for (int i = 1; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
topURL = SVNPathUtil.getCommonPathAncestor(topURL, pair.mySource);
}
if (copyPairs.size() == 1) {
topURL = SVNPathUtil.getCommonPathAncestor(topURL, topDstURL);
} else {
topURL = SVNPathUtil.getCommonPathAncestor(topURL, SVNPathUtil.removeTail(topDstURL));
}
try {
SVNURL.parseURIEncoded(topURL);
} catch (SVNException e) {
topURL = null;
}
if (topURL == null) {
SVNURL url1 = SVNURL.parseURIEncoded(((CopyPair) copyPairs.get(0)).mySource);
SVNURL url2 = SVNURL.parseURIEncoded(((CopyPair) copyPairs.get(0)).myDst);
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Source and dest appear not to be in the same repository (src: ''{0}''; dst: ''{1}'')", new Object[] {url1, url2});
SVNErrorManager.error(err, SVNLogType.WC);
}
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
CopyPathInfo info = (CopyPathInfo) pathInfos.get(i);
if (pair.mySource.equals(pair.myDst)) {
info.isResurrection = true;
if (topURL.equals(pair.mySource)) {
topURL = SVNPathUtil.removeTail(topURL);
}
}
}
SVNRepository topRepos = createRepository(SVNURL.parseURIEncoded(topURL), null, null, true);
List newDirs = new ArrayList();
if (makeParents) {
CopyPair pair = (CopyPair) copyPairs.get(0);
String relativeDir = SVNPathUtil.getPathAsChild(topURL, SVNPathUtil.removeTail(pair.myDst));
if (relativeDir != null) {
relativeDir = SVNEncodingUtil.uriDecode(relativeDir);
SVNNodeKind kind = topRepos.checkPath(relativeDir, -1);
while(kind == SVNNodeKind.NONE) {
newDirs.add(relativeDir);
relativeDir = SVNPathUtil.removeTail(relativeDir);
kind = topRepos.checkPath(relativeDir, -1);
}
}
}
String rootURL = topRepos.getRepositoryRoot(true).toString();
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
CopyPathInfo info = (CopyPathInfo) pathInfos.get(i);
if (!pair.myDst.equals(rootURL) && SVNPathUtil.getPathAsChild(pair.myDst, pair.mySource) != null) {
info.isResurrection = true;
// TODO still looks like a bug.
// if (SVNPathUtil.removeTail(pair.myDst).equals(topURL)) {
topURL = SVNPathUtil.removeTail(topURL);
// }
}
}
topRepos.setLocation(SVNURL.parseURIEncoded(topURL), false);
long latestRevision = topRepos.getLatestRevision();
for (int i = 0; i < copyPairs.size(); i++) {
CopyPair pair = (CopyPair) copyPairs.get(i);
CopyPathInfo info = (CopyPathInfo) pathInfos.get(i);
pair.mySourceRevisionNumber = getRevisionNumber(pair.mySourceRevision, topRepos, null);
info.mySourceRevisionNumber = pair.mySourceRevisionNumber;
SVNRepositoryLocation[] locations = getLocations(SVNURL.parseURIEncoded(pair.mySource), null, topRepos, pair.mySourcePegRevision, pair.mySourceRevision, SVNRevision.UNDEFINED);
pair.mySource = locations[0].getURL().toString();
String srcRelative = SVNPathUtil.getPathAsChild(topURL, pair.mySource);
if (srcRelative != null) {
srcRelative = SVNEncodingUtil.uriDecode(srcRelative);
} else {
srcRelative = "";
}
String dstRelative = SVNPathUtil.getPathAsChild(topURL, pair.myDst);
if (dstRelative != null) {
dstRelative = SVNEncodingUtil.uriDecode(dstRelative);
} else {
dstRelative = "";
}
if ("".equals(srcRelative) && isMove) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot move URL ''{0}'' into itself", SVNURL.parseURIEncoded(pair.mySource));
SVNErrorManager.error(err, SVNLogType.WC);
}
info.mySourceKind = topRepos.checkPath(srcRelative, pair.mySourceRevisionNumber);
if (info.mySourceKind == SVNNodeKind.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND,
"Path ''{0}'' does not exist in revision {1}", new Object[] {SVNURL.parseURIEncoded(pair.mySource), new Long(pair.mySourceRevisionNumber)});
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNNodeKind dstKind = topRepos.checkPath(dstRelative, latestRevision);
if (dstKind != SVNNodeKind.NONE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_ALREADY_EXISTS,
"Path ''{0}'' already exists", dstRelative);
SVNErrorManager.error(err, SVNLogType.WC);
}
info.mySource = pair.mySource;
info.mySourcePath = srcRelative;
info.myDstPath = dstRelative;
}
List paths = new ArrayList(copyPairs.size() * 2);
List commitItems = new ArrayList(copyPairs.size() * 2);
if (makeParents) {
for (Iterator newDirsIter = newDirs.iterator(); newDirsIter.hasNext();) {
String dirPath = (String) newDirsIter.next();
SVNURL itemURL = SVNURL.parseURIEncoded(SVNPathUtil.append(topURL, dirPath));
SVNCommitItem item = new SVNCommitItem(null, itemURL, null, SVNNodeKind.NONE, null, null, true, false, false, false, false, false);
commitItems.add(item);
}
}
for (Iterator infos = pathInfos.iterator(); infos.hasNext();) {
CopyPathInfo info = (CopyPathInfo) infos.next();
SVNURL itemURL = SVNURL.parseURIEncoded(SVNPathUtil.append(topURL, info.myDstPath));
SVNCommitItem item = new SVNCommitItem(null, itemURL, null, SVNNodeKind.NONE, null, null, true, false, false, false, false, false);
commitItems.add(item);
pathsMap.put(info.myDstPath, info);
if (isMove && !info.isResurrection) {
itemURL = SVNURL.parseURIEncoded(SVNPathUtil.append(topURL, info.mySourcePath));
item = new SVNCommitItem(null, itemURL, null, SVNNodeKind.NONE, null, null, false, true, false, false, false, false);
commitItems.add(item);
pathsMap.put(info.mySourcePath, info);
}
}
if (makeParents) {
for (Iterator newDirsIter = newDirs.iterator(); newDirsIter.hasNext();) {
String dirPath = (String) newDirsIter.next();
CopyPathInfo info = new CopyPathInfo();
info.myDstPath = dirPath;
info.isDirAdded = true;
paths.add(info.myDstPath);
pathsMap.put(dirPath, info);
}
}
for (Iterator infos = pathInfos.iterator(); infos.hasNext();) {
CopyPathInfo info = (CopyPathInfo) infos.next();