Better support for reverting new and deleted files #198
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently if you run a revert on a deleted file through the source control submit window, you don't actually get the file back because of this piece of code:
// If already queued for deletion, don't try to delete again if (State->IsSourceControlled() && !State->IsDeleted()) { OutMissingFiles.Add(State->GetFilename()); }
But the only place this function is used, is to revert files, so the revert action does nothing - with this change, the revert action will bring the file back to its state at HEAD - I had a bit of a look at the history of this, and it's quite unclear why it was needed, it was added quite a while back, I'd guess the engine used to handle deleting or reverting differently
In addition to this, the behavior of reverting an added file was just to unmark it for add - which is understandable that some folks would want that, but that's not the behavior we want at our studio, so I've made Revert on an added file also remove the file on disk IF you have USourceControlPreferences::ShouldDeleteNewFilesOnRevert() enabled
This is a property that already exists in the engine, and is used by the perforce integration to allow you to switch between the 2 behaviors listed here
There's also a general clean up, the code was a bit difficult to reason about, so I've refactored GetMissingVsExistingFiles into GroupFileCommandsForRevert which gives you lists of files sorted into buckets that we run different commands on so it's hopefully a bit simpler to follow