通过 C# 强制 TFS 签入文件
如何指定我始终希望本地文件替换服务器副本,即使 TFS 副本较新?
if (pendingChanges.GetUpperBound(0)>-1)
ChangeSetNumber = workspace.CheckIn(pendingChanges, filename);
我可以从智能感知中看到,我可以指定 checkinoptions 作为 CheckIn 方法的参数,我只是找不到需要放入的内容以使其始终签入并忽略我可能出现的任何冲突和。
提前致谢。
编辑:我发现了一个命令 TF RESOLVE "item" /auto:AcceptYours /recursive 所以我想我修改后的问题是是否有相当于 /auto:AcceptYours 开关的编程?
NecroEDIT:在签入之前处理冲突
Conflict[] conflicts = workspace.QueryConflicts(new string[] { TFSProject }, true); foreach (Conflict conflict in conflicts) { conflict.Resolution = Resolution.AcceptTheirs; workspace.ResolveConflict(conflict); }
How can I specify that I ALWAYS want the local file to replace the server copy even if the TFS copy is newer?
if (pendingChanges.GetUpperBound(0)>-1)
ChangeSetNumber = workspace.CheckIn(pendingChanges, filename);
I can see from the intelisense that I can specify checkinoptions as a parameter of the CheckIn method, I just cannot find what I need to put in to have it always check in and ignore any conflict I might come up with.
Thanks in advance.
EDIT: I found a command TF RESOLVE "item" /auto:AcceptYours /recursive So I guess my revised question would be is there a programming equivalent to the /auto:AcceptYours switch?
NecroEDIT: process the conflicts before doing the checkin
Conflict[] conflicts = workspace.QueryConflicts(new string[] { TFSProject }, true); foreach (Conflict conflict in conflicts) { conflict.Resolution = Resolution.AcceptTheirs; workspace.ResolveConflict(conflict); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
签入是原子的——要么全部成功,要么全部失败。 如果在签入之前需要解决任何冲突,则签入操作将引发异常。(文档)
您必须评估签入是否存在冲突,然后通过 Workspace.ResolveConflict 解决 CheckinConflicts方法。
ResolveConflict 需要 CheckinConflict,并且 EvaluateCheckin 的结果(即 CheckinEvaluationResult)包括 CheckinConflicts。
此页面可能会有所帮助。
注意:checkinoptions 与您所问的内容无关。
希望这可以帮助。
Checkins are atomic - either they all succeed or they all fail. If there are any conflicts that need to be resolved before the check in, the check in operation will throw an exception. (Documentation)
You have to evaluate checkin for conflicts and then resolve the CheckinConflicts by Workspace.ResolveConflict Method.
ResolveConflict expects CheckinConflict, and result of the EvaluateCheckin (which is CheckinEvaluationResult) includes CheckinConflicts.
This page may help.
Note: checkinoptions is not related with what you are asking.
Hope this helps.