Team Foundation Server:从 PolicyBase 对象获取变更集 ID [英] Team Foundation Server: Getting the Changeset Id from PolicyBase object

查看:22
本文介绍了Team Foundation Server:从 PolicyBase 对象获取变更集 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C# 在 Visual Studio 2010 中编写自定义签入策略.我扩展了类 PolicyBase 并覆盖了 Evaluate() 方法,以便我可以检查用户的签入注释是否包含特定信息.我正在使用 this.PendingCheckin.PendingChanges.Comment 获取用户的签到评论

I'm writing a custom check-in policy in Visual Studio 2010 using C#. I've extended the class PolicyBase and overriden the Evaluate() method so that I can check the user's check-in comment contains specific information. I'm getting the user's check-in comment using this.PendingCheckin.PendingChanges.Comment

我希望能够做的是提取将分配给签入的变更集编号.我从哪里以及如何获得这个号码?

What I would like to be able to do is pull out the changeset number that will be assigned to the check-in. Where and how would I get this number?

我猜测 Evaluate 方法是错误的地方,因为变更集在那时已经提交,因此无法确定变更集编号.

I'm guessing the Evaluate method is the wrong place because the changeset has been committed at that point and thus the changeset number cannot be determined.

TIA

推荐答案

对于签入策略,您无法以任何程度的确定性执行此操作,因为它们仅在预签入 中进行评估.当您进行签入时,服务器会为您分配变更集.

You cannot do this with any degree of certainty with a check-in policy, as they are only evaluated pre-checkin. The server assigns you the changeset when you do the checkin.

您可以尝试通过在 $/上查询历史来推断下一个变更集编号(返回的历史项目限制为 1 个).但很明显,如果您依赖此值,您将面临竞争条件 - 有人可以轻松击败您进行下一次签到,从而获取您认为下一次的号码.

You could try to deduce the next changeset number by querying history on $/ (with a limit of 1 history item returned). But obviously you will have a race condition if you depend on this value - someone could easily beat you to the next checkin, thus taking the number you think will be next.

也就是说,您可以在签入策略框架之外获取签入数据.您可以 CommitCheckin 事件连接到 Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer 的实例,或者您可以连接 当发生签入时会通知您的警报.

That said, you can get data about check-ins outside of the check-in policy framework. You can either hook up a CommitCheckin event to an instance of Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer, or you can hook up an alert that will notify you when a check-in occurs.

这篇关于Team Foundation Server:从 PolicyBase 对象获取变更集 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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