} else {   if (versionedDir.getParentFile() != null) { return getWorkingCopyRoot(versionedDir.getParentFile(), stopOnExtenrals); } return versionedDir;
    public static File getWorkingCopyRoot(File versionedDir,            boolean stopOnExtenrals) {        versionedDir = versionedDir.getAbsoluteFile();        if (versionedDir == null                || (!isVersionedDirectory(versionedDir) && !isVersionedDirectory(versionedDir.getParentFile()))) {            // both this dir and its parent are not versioned.            return null;        }        if (isWorkingCopyRoot(versionedDir, true)) {            // this is root.            if (stopOnExtenrals) {                return versionedDir;            }            File parent = versionedDir.getParentFile();            File parentRoot = getWorkingCopyRoot(parent, stopOnExtenrals);            if (parentRoot == null) {                // if parent is not versioned return this dir.                return versionedDir;            }            // parent is versioned. we have to check if it contains externals            // definition for this dir.            while (parent != null) {                try {                    SVNWCAccess parentAccess = SVNWCAccess.create(parent);                    SVNProperties props = parentAccess.getTarget()                            .getProperties("", false);                    SVNExternalInfo[] externals = SVNWCAccess.parseExternals(                            "", props.getPropertyValue(SVNProperty.EXTERNALS));                    // now externals could point to our dir.                    for (int i = 0; i < externals.length; i++) {                        SVNExternalInfo external = externals[i];                        File externalFile = new File(parent, external.getPath());                        if (externalFile.equals(versionedDir)) {                            return parentRoot;                        }                    }                } catch (SVNException e) {                    //                }                if (parent.equals(parentRoot)) {                    break;                }                parent = parent.getParentFile();            }            return versionedDir;        } else {            // if dir is not a root -> just recurse till root, the call get root            // again.            if (versionedDir.getParentFile() != null) {                return getWorkingCopyRoot(versionedDir.getParentFile(), stopOnExtenrals);            }            return versionedDir;        }    }