if (!lockAll) {
if (!lockAll) { Collection uniqueDirsToLockRecursively = new TreeSet(SVNPathUtil.PATH_COMPARATOR); uniqueDirsToLockRecursively.addAll(dirsToLockRecursively); for(Iterator ps = uniqueDirsToLockRecursively.iterator(); ps.hasNext();) { String pathToLock = (String) ps.next(); for(Iterator existing = dirsToLockRecursively.iterator(); existing.hasNext();) { String existingPath = (String) existing.next(); if (pathToLock.startsWith(existingPath + "/")) {  ps.remove(); break; } }  } dirsToLockRecursively = uniqueDirsToLockRecursively;
    public static SVNWCAccess createCommitWCAccess(File[] paths, boolean recursive, boolean force, Collection relativePaths, final SVNStatusClient statusClient) throws SVNException {        String[] validatedPaths = new String[paths.length];        for (int i = 0; i < paths.length; i++) {            statusClient.checkCancelled();            File file = paths[i];            validatedPaths[i] = SVNPathUtil.validateFilePath(file.getAbsolutePath());        }        String rootPath = SVNPathUtil.condencePaths(validatedPaths, relativePaths, recursive);        if (rootPath == null) {            return null;        }        File baseDir = new File(rootPath);        Collection dirsToLock = new TreeSet(); // relative paths to lock.        Collection dirsToLockRecursively = new TreeSet();         boolean lockAll = false;        if (relativePaths.isEmpty()) {            statusClient.checkCancelled();            String target = getTargetName(baseDir);            if (!"".equals(target)) {                // we will have to lock target as well, not only base dir.                SVNFileType targetType = SVNFileType.getType(new File(rootPath));                relativePaths.add(target);                if (targetType == SVNFileType.DIRECTORY) {                    // lock recursively if forced and copied...                    if (recursive || (force && isRecursiveCommitForced(baseDir))) {                        // dir is copied, include children                        dirsToLockRecursively.add(target);                    } else {                        dirsToLock.add(target);                    }                  }                baseDir = baseDir.getParentFile();            } else {                lockAll = true;            }        } else {            baseDir = adjustRelativePaths(baseDir, relativePaths);            // there are multiple paths.            for (Iterator targets = relativePaths.iterator(); targets.hasNext();) {                statusClient.checkCancelled();                String targetPath = (String) targets.next();                File targetFile = new File(baseDir, targetPath);                SVNFileType targetKind = SVNFileType.getType(targetFile);                if (targetKind == SVNFileType.DIRECTORY) {                    if (recursive || (force && isRecursiveCommitForced(targetFile))) {                        dirsToLockRecursively.add(targetPath);                    } else if (!targetFile.equals(baseDir)){                        dirsToLock.add(targetPath);                    }                }                if (!targetFile.equals(baseDir)) {                    targetFile = targetFile.getParentFile();                    targetPath = SVNPathUtil.removeTail(targetPath);                    while (!targetFile.equals(baseDir) && !dirsToLock.contains(targetPath)) {                        dirsToLock.add(targetPath);                        targetPath = SVNPathUtil.removeTail(targetPath);                        targetFile = targetFile.getParentFile();                    }                }            }        }        SVNWCAccess baseAccess = SVNWCAccess.newInstance(new ISVNEventHandler() {            public void handleEvent(SVNEvent event, double progress) throws SVNException {            }            public void checkCancelled() throws SVNCancelException {                statusClient.checkCancelled();            }        });        baseAccess.setOptions(statusClient.getOptions());        try {            baseAccess.open(baseDir, true, lockAll ? SVNWCAccess.INFINITE_DEPTH : 0);            statusClient.checkCancelled();            if (!lockAll) {                                removeRedundantPaths(dirsToLockRecursively, dirsToLock);                for (Iterator nonRecusivePaths = dirsToLock.iterator(); nonRecusivePaths.hasNext();) {                    statusClient.checkCancelled();                    String path = (String) nonRecusivePaths.next();                    File pathFile = new File(baseDir, path);                    baseAccess.open(pathFile, true, 0);                }                for (Iterator recusivePaths = dirsToLockRecursively.iterator(); recusivePaths.hasNext();) {                    statusClient.checkCancelled();                    String path = (String) recusivePaths.next();                    File pathFile = new File(baseDir, path);                    baseAccess.open(pathFile, true, SVNWCAccess.INFINITE_DEPTH);                }            }            for(int i = 0; i < paths.length; i++) {                statusClient.checkCancelled();                File path = new File(SVNPathUtil.validateFilePath(paths[i].getAbsolutePath()));                try {                    baseAccess.probeRetrieve(path);                } catch (SVNException e) {                    SVNErrorMessage err = e.getErrorMessage().wrap("Are all the targets part of the same working copy?");                    SVNErrorManager.error(err);                }                if (!recursive && !force) {                    if (SVNFileType.getType(path) == SVNFileType.DIRECTORY) {                        // TODO replace with direct SVNStatusEditor call.                        SVNStatus status = statusClient.doStatus(path, false);                        if (status != null && (status.getContentsStatus() == SVNStatusType.STATUS_DELETED || status.getContentsStatus() == SVNStatusType.STATUS_REPLACED)) {                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Cannot non-recursively commit a directory deletion");                            SVNErrorManager.error(err);                        }                    }                }            }            // if commit is non-recursive and forced, remove those child dirs             // that were not explicitly added but are explicitly copied. ufff.            if (!recursive && force) {                SVNAdminArea[] lockedDirs = baseAccess.getAdminAreas();                for (int i = 0; i < lockedDirs.length; i++) {                    statusClient.checkCancelled();                    SVNAdminArea dir = lockedDirs[i];                    SVNEntry rootEntry = baseAccess.getEntry(dir.getRoot(), true);                    if (rootEntry.getCopyFromURL() != null) {                        File dirRoot = dir.getRoot();                        boolean keep = false;                        for (int j = 0; j < paths.length; j++) {                            if (dirRoot.equals(paths[j])) {                                keep = true;                                break;                            }                        }                        if (!keep) {                            baseAccess.closeAdminArea(dir.getRoot());                        }                    }                }            }        } catch (SVNException e) {            baseAccess.close();            throw e;        }        baseAccess.setAnchor(baseDir);        return baseAccess;    }