How to disable or remove candidate changes in TFS

為{幸葍}努か 提交于 2019-12-13 06:15:43

问题


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


回答1:


In TFS there are two kinds of moving files. I have crated a sample for both :

Local Workspace (window exploer) directly move/drag file

  1. In the disk my workspace, I'm going to move 2.PNG to Main-branch folder

  1. 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.

  2. 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

  1. In the solution explorer , I'm going to move 1.PNG to Main folder by right click and select move.

  1. You will get a pending change with rename status directly and not any Promote Candidate Changes.

  2. 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 :

updateDisk

If true, the local disk is updated according to the pending changes; if false, the disk is not modified and changes are not acknowledged.

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.



来源:https://stackoverflow.com/questions/42661527/how-to-disable-or-remove-candidate-changes-in-tfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!