String dstURL = wcAccess.getAnchor().getEntries() .getPropertyValue("", SVNProperty.URL); dstURL = SVNPathUtil.append(dstURL, SVNEncodingUtil.uriEncode(dstPath .getName())); SVNDirectory targetDir = createVersionedDirectory(dstPath, dstURL, uuid, srcRevision); SVNWCAccess wcAccess2 = new SVNWCAccess(targetDir, targetDir, "");
SVNURL dstURL = wcAccess.getAnchor().getEntries().getEntry("", false).getSVNURL(); dstURL = dstURL.appendPath(dstPath.getName(), false); SVNDirectory targetDir = createVersionedDirectory(dstPath, dstURL, uuid, srcRevision); SVNWCAccess wcAccess2 = new SVNWCAccess(targetDir, targetDir, "");
    private void url2wcCopy(String srcURL, long srcRevision, File dstPath)            throws SVNException {        SVNRepository repos = createRepository(srcURL);        SVNNodeKind srcKind = repos.checkPath("", srcRevision);        if (srcKind == SVNNodeKind.NONE) {            SVNErrorManager.error("svn: URL '" + srcURL + "' does not exist");        }        String srcUUID = repos.getRepositoryUUID();        if (dstPath.isDirectory()) {            dstPath = new File(dstPath, SVNEncodingUtil.uriDecode(SVNPathUtil.tail(srcURL)));            if (dstPath.exists()) {                SVNErrorManager.error("svn: Path '" + dstPath + "' already exists");            }        } else if (dstPath.exists()) {            SVNErrorManager.error("svn: Path '" + dstPath + "' already exists");        }        boolean sameRepositories;        SVNWCAccess wcAccess = createWCAccess(dstPath);        try {            wcAccess.open(true, false);            // check for missing entry.            SVNEntry entry = wcAccess.getAnchor().getEntries().getEntry(wcAccess.getTargetName(), false);            if (entry != null && !entry.isDirectory()) {                SVNErrorManager.error("svn: '" + dstPath + "' is already under version control");            }            String uuid = wcAccess.getTargetEntryProperty(SVNProperty.UUID);            sameRepositories = uuid.equals(srcUUID);            if (srcKind == SVNNodeKind.DIR) {                String dstURL = wcAccess.getAnchor().getEntries()                        .getPropertyValue("", SVNProperty.URL);                dstURL = SVNPathUtil.append(dstURL, SVNEncodingUtil.uriEncode(dstPath                        .getName()));                SVNDirectory targetDir = createVersionedDirectory(dstPath,                        dstURL, uuid, srcRevision);                SVNWCAccess wcAccess2 = new SVNWCAccess(targetDir, targetDir,                        "");                wcAccess2.open(true, true);                setDoNotSleepForTimeStamp(true);                try {                    SVNReporter reporter = new SVNReporter(wcAccess2, true,                            true);                    SVNUpdateEditor editor = new SVNUpdateEditor(wcAccess2,                            null, true, isLeaveConflictsUnresolved());                    repos.update(srcRevision, null, true, reporter, editor);                    dispatchEvent(SVNEventFactory.createUpdateCompletedEvent(                            wcAccess, editor.getTargetRevision()));                    if (sameRepositories) {                        addDir(wcAccess.getAnchor(), dstPath.getName(), srcURL,                                editor.getTargetRevision());                        addDir(wcAccess2.getAnchor(), "", srcURL, editor                                .getTargetRevision());                        dispatchEvent(SVNEventFactory.createAddedEvent(                                wcAccess, wcAccess.getAnchor(), wcAccess                                        .getAnchor().getEntries().getEntry(                                                dstPath.getName(), true)));                    } else {                        SVNErrorManager.error("svn: '" + dstPath.getParentFile() + "' belongs to different repository then '" + srcURL + "'");                    }                } finally {                    setDoNotSleepForTimeStamp(false);                    wcAccess2.close(true);                }            } else {                Map properties = new HashMap();                File tmpFile = null;                File baseTmpFile = wcAccess.getAnchor().getBaseFile(dstPath.getName(), true);                tmpFile = SVNFileUtil.createUniqueFile(baseTmpFile.getParentFile(), dstPath.getName(), ".tmp");                OutputStream os = SVNFileUtil.openFileForWriting(tmpFile);                try {                    repos.getFile("", srcRevision, properties, os);                } finally {                    SVNFileUtil.closeFile(os);                }                SVNFileUtil.rename(tmpFile, baseTmpFile);                if (tmpFile != null) {                    tmpFile.delete();                }                addFile(wcAccess.getAnchor(), dstPath.getName(), properties,                        sameRepositories ? srcURL : null, srcRevision);                wcAccess.getAnchor().runLogs();                dispatchEvent(SVNEventFactory.createAddedEvent(wcAccess,                        wcAccess.getAnchor(), wcAccess.getAnchor().getEntries()                                .getEntry(dstPath.getName(), true)));            }        } finally {            if (wcAccess != null) {                wcAccess.close(true);            }            if (!isDoNotSleepForTimeStamp()) {                SVNFileUtil.sleepForTimestamp();            }        }    }