ArrayList<VirtualFile> modifiedFiles = new ArrayList<VirtualFile>();
ArrayList<VirtualFile> addedFiles = new ArrayList<VirtualFile>();
List<VcsException> exceptions = new ArrayList<VcsException>();
for (Change change : changes) {
if (FileStatus.MODIFIED.equals(change.getFileStatus())) {
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null) {
FilePath filePath = afterRevision.getFile();
modifiedFiles.add(VcsUtil.getVirtualFile(filePath.getIOFile()));
}
} else if (FileStatus.ADDED.equals(change.getFileStatus())) {
addedFiles.add(change.getAfterRevision().getFile().getVirtualFile());
}else {
exceptions.add(new VcsException("only MODIFIED/ADDED (!= "+change.getFileStatus()+"files are currently supported" ));
}
}
RevertAPICommand revertAPICommand = new RevertAPICommand();
try {
List<VirtualFile> filesToRevert = new ArrayList<VirtualFile>();
filesToRevert.addAll(modifiedFiles);
filesToRevert.addAll(addedFiles);
revertAPICommand.executeCommand(mksVcs, exceptions, filesToRevert.toArray(new VirtualFile[filesToRevert.size()]));
} catch (VcsException e) {
//noinspection ThrowableInstanceNeverThrown
exceptions.add(e);
}
for (Change change : changes) {
File beforePath = null;
logger.debug("MksRollbackEnvironment.rollbackChanges " + change);
ContentRevision beforeRevision = change.getBeforeRevision();
if (beforeRevision != null && beforeRevision instanceof MksContentRevision) {
// file was not created by change
beforePath = beforeRevision.getFile().getIOFile();
revert(beforePath, vcsExceptions);
}
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null) {
File afterPath = afterRevision.getFile().getIOFile();
if (!afterPath.equals(beforePath)) {
// todo file has been renamed !!!
/*
UnversionedFilesCollector collector = new UnversionedFilesCollector();
try {