DebugLog.log("reverted, unscheduling target root entry: " + wcAccess.getTarget().getRoot());
    public void doRevert(File path, boolean recursive) throws SVNException {        SVNWCAccess wcAccess = createWCAccess(path);        // force recursive lock.        boolean reverted = false;        boolean replaced = false;        SVNNodeKind kind = null;        Collection recursiveFiles = new ArrayList();        try {            wcAccess.open(true, false);            SVNEntry entry = wcAccess.getAnchor().getEntries().getEntry(                    wcAccess.getTargetName(), true);            if (entry == null) {                SVNErrorManager.error("svn: '" + path                        + "' is not under version control");            }            kind = entry.getKind();            File file = wcAccess.getAnchor().getFile(wcAccess.getTargetName());            if (entry.isDirectory()) {                if (!entry.isScheduledForAddition() && !file.isDirectory()) {                    handleEvent(SVNEventFactory.createNotRevertedEvent(                            wcAccess, wcAccess.getAnchor(), entry),                            ISVNEventHandler.UNKNOWN);                    return;                }            }            SVNEvent event = SVNEventFactory.createRevertedEvent(wcAccess,                    wcAccess.getAnchor(), entry);            if (entry.isScheduledForAddition()) {                boolean deleted = entry.isDeleted();                if (entry.isFile()) {                    wcAccess.getAnchor().destroy(entry.getName(), false);                } else if (entry.isDirectory()) {                    if ("".equals(wcAccess.getTargetName())) {                        SVNErrorManager                                .error("svn: Cannot revert addition of the root directory; please try again from the parent directory");                    }                    if (!file.exists()) {                        wcAccess.getAnchor().getEntries().deleteEntry(                                entry.getName());                    } else {                        wcAccess.open(true, true, true);                        wcAccess.getAnchor().destroy(entry.getName(), false);                    }                }                reverted = true;                if (deleted && !"".equals(wcAccess.getTargetName())) {                    // we are not in the root.                    SVNEntry replacement = wcAccess.getAnchor().getEntries()                            .addEntry(entry.getName());                    replacement.setDeleted(true);                    replacement.setKind(kind);                }            } else if (entry.isScheduledForReplacement()                    || entry.isScheduledForDeletion()) {                replaced = entry.isScheduledForReplacement();                if (entry.isDirectory()) {                    reverted |= wcAccess.getTarget().revert("");                } else {                    reverted |= wcAccess.getAnchor().revert(entry.getName());                }                reverted = true;            } else {                if (entry.isDirectory()) {                    reverted |= wcAccess.getTarget().revert("");                } else {                    reverted |= wcAccess.getAnchor().revert(entry.getName());                }            }            if (reverted) {                if (kind == SVNNodeKind.DIR && replaced) {                    recursive = true;                }                if (!"".equals(wcAccess.getTargetName())) {                    entry.unschedule();                    entry.setConflictNew(null);                    entry.setConflictOld(null);                    entry.setConflictWorking(null);                    entry.setPropRejectFile(null);                }                wcAccess.getAnchor().getEntries().save(false);                if (kind == SVNNodeKind.DIR) {                    DebugLog.log("reverted, unscheduling target root entry: "                            + wcAccess.getTarget().getRoot());                    SVNEntry inner = wcAccess.getTarget().getEntries()                            .getEntry("", true);                    if (inner != null) {                        // may be null if it was removed from wc.                        inner.unschedule();                        inner.setConflictNew(null);                        inner.setConflictOld(null);                        inner.setConflictWorking(null);                        inner.setPropRejectFile(null);                    }                }                wcAccess.getTarget().getEntries().save(false);            }            if (kind == SVNNodeKind.DIR && recursive) {                // iterate over targets and revert                for (Iterator ents = wcAccess.getTarget().getEntries().entries(                        true); ents.hasNext();) {                    SVNEntry childEntry = (SVNEntry) ents.next();                    if ("".equals(childEntry.getName())) {                        continue;                    }                    recursiveFiles.add(wcAccess.getTarget().getFile(childEntry.getName()));                }            }            if (reverted) {                // fire reverted event.                handleEvent(event, ISVNEventHandler.UNKNOWN);            }        } finally {            wcAccess.close(true);        }        // recurse        if (kind == SVNNodeKind.DIR && recursive) {            // iterate over targets and revert            for (Iterator files = recursiveFiles.iterator(); files.hasNext();) {                File file = (File) files.next();                doRevert(file, recursive);            }        }    }