如何在TFS中禁用或删除候选更改 [英] How to disable or remove candidate changes in TFS

查看:92
本文介绍了如何在TFS中禁用或删除候选更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将tfs工作区中的文件移出tfs之外(例如,通过Windows资源管理器)时,tfs会将这些移动作为删除和添加.

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.

要解决此问题,我运行了一个程序,该程序监视更改,并在发生移动时执行将updateDisk设置为false的Workspace.PendRename.

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.

除了tfs将该删除添加为候选更改外,此方法工作正常.

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.

通过使用Workspace.GetPendingChangesWithCandidates,我可以获得候选更改,但是似乎没有什么办法可以将其从列表中删除.

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.

在执行PendRename之前,我尝试将文件移回其原始位置(File.Move),然后在updateDisk设置为true的情况下执行PendRename.这实际上对单个文件有效,但是在涉及文件夹等文件时会变得复杂.

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.

我希望有一种简单的方法可以从列表中删除候选更改,或者甚至完全禁用某些文件/文件夹的候选更改功能.我尝试将文件夹添加到.tfignore文件,但这不起作用.

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.

升级候选更改"显示删除,即使文件已重命名

推荐答案

在TFS中,有两种移动文件.我为这两个都创建了一个示例:

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

  1. 在磁盘上,我将工作区 2.PNG 移至 Main-branch 文件夹
  1. In the disk my workspace, I'm going to move 2.PNG to Main-branch folder

  1. 然后我们可以检查TFS在VS中检测到的内容.加一个(在新的 位置),在促进候选者更改"中删除(在旧位置).

  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.

您需要同时检查添加和删除(首先升级).最后 您将获得所需的服务器和本地服务器.

You need to check in both the add and delete ( promote first). Finally you will get what you want both server and local.

直接在解决方案资源管理器中移动文件

  1. 在解决方案资源管理器中,我将把 1.PNG 移到 Main 右键单击文件夹,然后选择移动".
  1. In the solution explorer , I'm going to move 1.PNG to Main folder by right click and select move.

  1. 您将直接获得状态为重命名的待处理更改, 没有任何促进候选人变更.

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

然后我们可以检查本地工作区,您将看到1.PNG是 在工作区文件夹中自动删除,即使您尚未签入更改也是如此.最后检查待处理 变化,一切都很好,很干净.

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.


回到您的问题:升级候选更改显示删除,即使文件已重命名.

TFS API应该使用上面的方法2.查看参数:

The TFS API should be using the way 2 above. Look at the parameters :

updateDisk

如果为true,则根据挂起的更改来更新本地磁盘;否则,将更新本地磁盘. 如果为false,则磁盘未修改且更改未进行 确认.

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

因此,如果将 updateDisk 设置为 false ,则1.PNG仍应存在于磁盘中,并且TFS会检测到该磁盘,并添加了促进候选更改显示删除.哪个符合您的屏幕截图.解决方案应该是将值从false更改为 true .

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.

这篇关于如何在TFS中禁用或删除候选更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆