}
private boolean doRevert(File path, SVNAdminArea parent, SVNDepth depth, boolean useCommitTimes,
Collection changeLists) throws SVNException {
checkCancelled();
SVNWCAccess wcAccess = parent.getWCAccess();
SVNAdminArea dir = wcAccess.probeRetrieve(path);
SVNEntry entry = wcAccess.getEntry(path, false);
SVNTreeConflictDescription treeConflict = wcAccess.getTreeConflict(path);
if (entry == null && treeConflict == null) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "Cannot revert unversioned item ''{0}''",
path);
SVNErrorManager.error(err, SVNLogType.WC);
}
if (entry != null && entry.getKind() == SVNNodeKind.DIR) {
SVNFileType fileType = SVNFileType.getType(path);
if (fileType != SVNFileType.DIRECTORY && !entry.isScheduledForAddition()) {
if (isRevertMissingDirectories() && entry.getSchedule() != null && !entry.isThisDir()) {
// missing directory scheduled for deletion in parent.
boolean reverted = revert(parent, entry.getName(), entry, useCommitTimes);
if (reverted) {
SVNEvent event = SVNEventFactory.createSVNEvent(dir.getFile(entry.getName()), entry.getKind(), null, entry.getRevision(),
SVNEventAction.REVERT, null, null, null);
dispatchEvent(event);
}
return reverted;
}
SVNEvent event = SVNEventFactory.createSVNEvent(dir.getFile(entry.getName()), entry.getKind(), null, entry.getRevision(), SVNEventAction.FAILED_REVERT, null, null, null);
dispatchEvent(event);
return false;
}
}
if (entry != null && entry.getKind() != SVNNodeKind.DIR && entry.getKind() != SVNNodeKind.FILE) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"Cannot revert ''{0}'': unsupported entry node kind", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
SVNFileType fileType = SVNFileType.getType(path);
if (fileType == SVNFileType.UNKNOWN) {
SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
"Cannot revert ''{0}'': unsupported node kind in working copy", path);
SVNErrorManager.error(err, SVNLogType.WC);
}
boolean reverted = false;
if (SVNWCAccess.matchesChangeList(changeLists, entry)) {
if (treeConflict != null) {
parent.deleteTreeConflict(path.getName());
reverted = true;
}
if (entry != null) {
if (entry.isScheduledForAddition()) {
boolean wasDeleted = false;
if (entry.getKind() == SVNNodeKind.FILE) {
wasDeleted = entry.isDeleted();
parent.removeFromRevisionControl(path.getName(), false, false);
} else if (entry.getKind() == SVNNodeKind.DIR) {
SVNEntry entryInParent = parent.getEntry(path.getName(), true);
if (entryInParent != null) {
wasDeleted = entryInParent.isDeleted();
}
if (fileType == SVNFileType.NONE || wcAccess.isMissing(path)) {
parent.deleteEntry(path.getName());
parent.saveEntries(false);
} else {
dir.removeFromRevisionControl("", false, false);
}