Mercurial挂钩:如何在提交时查找当前目录 [英] Mercurial hooks: how to find the current directory on commit
问题描述
我正在尝试使用C#.NET创建与Mercurial SCM(hg)的钩子,以在提交或预提交时启动自定义C#应用程序.
I am trying to create a hook to Mercurial SCM (hg) using C# .NET, to launch a custom C# application on commit or pre-commit.
作为概念验证的原型,我在Mercurial.ini文件的[hooks]节中添加了自定义.exe的位置以进行预提交,并在另一个.exe中进行提交. 这些.exe应用程序会按预期在预提交和提交时打开.
As a proof-of-concept prototype, I added a location of my custom .exe to the Mercurial.ini file's [hooks] section for pre-commit, and another .exe for commit. Those .exe apps open on pre-commit and commit, as expected.
但是,到目前为止,这些可执行文件只是存根. 为了使他们能够执行我需要的工作,他们必须知道"即将发生(或已经发生)提交的当前目录. Mercurial.ini位于Windows上的用户配置文件目录中. 例如,当我从C:\ MyProjects \ TestProject中的Hg存储库中提交内容时,可执行文件需要知道工作正在C:\ MyProjects \ TestProject中完成.
However, those executables are only stubs so far. To make them do what I need, they have to "know" the current directory where the commit is about to occur (or has occurred). Mercurial.ini is located in my user profile directory on Windows. For example, when I do a commit from an Hg repository located in C:\MyProjects\TestProject, the executables need to know that the work is being done in C:\MyProjects\TestProject.
如何在运行时以编程方式从本地计算机上正在执行Mercurial命令的挂钩"可执行文件中查找?
How can I find out programmatically at runtime from a "hooked" executable where the Mercurial command is being executed on the local machine?