in src/com/intellij/vssSupport/Checkin/VssRollbackEnvironment.java [162:235]
private void rollbackChanged( List<Change> changes, HashSet<FilePath> processedFiles, List<VcsException> errors, @NotNull final RollbackProgressListener listener)
{
ArrayList<String> rollbacked = new ArrayList<>();
for( Change change : changes )
{
if( !VcsUtil.isChangeForNew( change ) &&
!VcsUtil.isChangeForDeleted( change ) &&
!VcsUtil.isChangeForFolder( change ) )
{
FilePath filePath = change.getAfterRevision().getFile();
String path = filePath.getPath();
listener.accept(change);
if( VcsUtil.isRenameChange( change ) )
{
// Track two different cases:
// - we delete the file which is already in the repository.
// Here we need to "Get" the latest version of the original
// file from the repository, make "UndoCheckout" for it (since
// it was obviously checked out for a rename change), and
// delete the new file.
// - we delete the renamed file which is new and does not exist
// in the repository. We need to ignore the error message from
// the SourceSafe ("file not existing") and just delete the
// new file.
List<VcsException> localErrs = new ArrayList<>();
final FilePath oldFile = change.getBeforeRevision().getFile();
boolean fileAbsent = host.getLatestVersion( oldFile.getPath(), false, localErrs );
if( fileAbsent )
errors.addAll( localErrs );
else
{
//-----------------------------------------------------------------
// 1. add marker telling that we do not want to track this file's
// deletion event.
// NB: VirtualFile for this file can be null if e.g. this renamed
// file occured within renamed folder. Folders are rollbacked
// first, so there could be no placeholder for the old file
// location.
// 2. WAIT for this file. Without this we aint be able to issue
// "Undo CheckOut" command since it work only on VirtualFiles.
// ToDO: refactor UndoCheckout so that it does not require VirtualFiles.
//-----------------------------------------------------------------
LocalFileSystem.getInstance().refreshAndFindFileByPath(oldFile.getPath());
VirtualFile vfile = filePath.getVirtualFile();
if( vfile != null )
vfile.putUserData( RENAME_ROLLBACK, true );
rollbacked.add( oldFile.getPath() );
}
host.renamedFiles.remove( path );
FileUtil.delete( new File( path ) );
}
else
{
path = discoverOldName( path );
// Collect all files to be uncheckouted into one set so that
// if dialog popups we could say "Yes to all"
rollbacked.add( path );
}
processedFiles.add( filePath );
}
}
if( rollbacked.size() > 0 )
{
String[] files = ArrayUtil.toStringArray(rollbacked);
host.rollbackChanges( files, errors );
}
}