Mercurial,使用.NET API编写钩子

zak*_*zak 18 .net c# vb.net mercurial

您好我正在寻找如何用.NET语言编写Mercurial钩子的示例,包括如何设置.hg/hgr

我使用了"Mercurial.Net"Api,但Windows环境变量中的信息有点受限,并且标准错误通道上的返回错误消息似乎不起作用.我想我做错了什么.

我使用.Net有很多原因,一个是使用WFC与其他系统连接

use*_*648 10

编辑新版本的Mercurial.Net使编写钩子变得更容易,请参阅http://mercurialnet.codeplex.com/discussions/261283

  1. 创建"Windows应用程序"项目(例如MyHook).
  2. 添加对"Mercurial.Net"的引用(您可以使用NuGet使其更容易http://nuget.org/List/Packages/Mercurial.Net).
  3. 在您的main方法中,执行您想要的任何处理(例如,检索日志,然后检索上次提交的信息 - 请参阅http://mercurialnet.codeplex.com/discussions/261283以获取示例).您可以添加一个MessageBox.Show(message)以检查钩子是否确实已执行.
  4. 编译您的项目.
  5. 将钩子添加到.hg/hgrc文件中(下面是每次提交后将执行的钩子的示例,请参阅https://www.mercurial-scm.org/wiki/Hook了解更多信息,http:// hgbook.red-bean.com/read/handling-repository-events-with-hooks.html了解更多信息):

    [hooks]
    commit.hook1 = "C:\path to file\MyHook.exe"
    
    Run Code Online (Sandbox Code Playgroud)

下次你提交你的钩子时应该执行.

检查http://docs.vkarlsen.no/Mercurial.Net/以了解Mercurial.Net的类.