VisualHG 中的自动提交

发布于 2025-01-04 07:07:15 字数 89 浏览 1 评论 0原文

是否可以设置 VisualHg,以便每次退出 Visual studio 2010 时都会自动显示提交屏幕?

如果我忘记提交一些更改,这将非常有用。

Is it possible to setup VisualHg such that i'm automatically presented with a commit screen every time I quit Visual studio 2010?

This would be extremely useful if I forget to commit some changes.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木有鱼丸 2025-01-11 07:07:15

我已设法使用以下步骤来完成此操作:

  1. 选择“工具”>“宏> VS 2010 IDE 中的宏 IDE。
  2. 这应该会向您显示一个空的 IDE,左侧有 Project Explorer
  3. 展开 MyMacros 并双击 EnvironmentEvents

这将为您提供一个设置为处理 IDE 事件的文件。在文件中的最后一个 End Module 之前添加以下代码:

Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
    DTE.ExecuteCommand("File.Commit")
End Sub

这将在解决方案关闭之前执行提交操作(这将在 Visual Studio 关闭之前发生),但 VS 不会等待提交窗口在继续之前关闭。这并不理想,因为这意味着如果您想在提交之前进行任何更改,则必须重新加载解决方案。

另一种解决方案是处理 QueryCloseSolution 事件并询问用户是否要在关闭之前提交更改。如果他们回答“是”,那么您将取消关闭解决方案(通过将传入的布尔值设置为 True)并调用 DTE.ExecuteCommand("File.Commit")。然后,当您进行提交时,解决方案将保持打开状态,但每次关闭解决方案时都会询问您是否要提交。

进一步采用该解决方案需要从 QueryCloseSolution 事件启动 hg status,以在询问用户是否要提交更改之前检查是否存在未完成的更改。

I've managed to do this using the following steps:

  1. Select Tools > Macros > Macros IDE from the VS 2010 IDE.
  2. This should present you with an empty IDE with Project Explorer on the left
  3. Expand MyMacros and double-click on EnvironmentEvents

This gives you a file which is set up to handle IDE events. Before the last End Module in the file add the following code:

Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
    DTE.ExecuteCommand("File.Commit")
End Sub

This will execute the commit action before the solution closes (which will happen before Visual Studio closes) but VS doesn't wait for the commit window to close before carrying on. This isn't ideal as it means that you'd have to re-load the solution if you wanted to make any changes before committing.

An alternative solution would be to handle the QueryCloseSolution event and ask the user if they want to commit their changes before closing. If they answer "Yes" then you'd cancel the close solution (by setting the passed in boolean to be True) and call DTE.ExecuteCommand("File.Commit"). That would then leave the solution open whilst you did your commit but would ask you if you wanted to commit every time you close the solution.

Taking that solution further would involve launching hg status from the QueryCloseSolution event to check if there are outstanding changes before asking the user if they want to commit their changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文