When files in a tfs workspace are moved outside of tfs (eg. through windows explorer), tfs picks these moves up as a delete and an add.
To get around this, I have a program running that monitors for changes and when a move happens I do a Workspace.PendRename with updateDisk set to false.
This works fine except that tfs adds the delete as a candidate change.
Is there anyway to remove this candidate change? It causes issues if people try and promote these changes.
By using Workspace.GetPendingChangesWithCandidates I can get the candidate change, but there doesn't seem to be anything I can do with it to remove it from the list.
Before doing the PendRename, I tried moving the file back to it's original location (File.Move) and then doing the PendRename with updateDisk set to true. This actually works well for single files, but gets complicated when folders and such are involved.
I'm hoping there's a simple way to either remove the candidate change from the list, or to even disable the candidate changes functionality altogether for certain files/folders. I tried adding the folder to the .tfignore file but that doesn't work.
Promote Candidate Changes shows deletes even though files were renamed
In TFS there are two kinds of moving files. I have crated a sample for both :
Local Workspace (window exploer) directly move/drag file
Then we could check what TFS detects in VS. One with add(in new place), one with delete(in old place) in Promote Candidate Changes.
You need to check in both the add and delete ( promote first). Finally you will get what you want both server and local.
Move a file in solution explorer directly
You will get a pending change with rename status directly and not any Promote Candidate Changes.
Then we could check our local workspace, you will see 1.PNG is automatically deleted in the workspace folder even though you haven't check in changes. Finally checking pending changes, everything is fine and clean.
Back to your question: Promote Candidate Changes shows deletes even though files were renamed.
The TFS API should be using the way 2 above. Look at the parameters :
So if you set the updateDisk to false , the 1.PNG should still exist in the disk and TFS detect it and adding to promote Candidate Changes shows deleted. Which meets your screenshot. The solution should be change the value from false to true.