Hi I am looking for examples of how to write Mercurial hooks in 开发者_如何学Goa .NET language, including how to setup .hg/hgr
I have used the "Mercurial.Net" Api, but the information in the Windows environment variables is a bit limited and returning error messages on the standard error channel does not appear to work. I guess I am doing something wrong.
I am using .Net for a number of reasons , one being to link up with other systems using WFC
EDIT The new version of Mercurial.Net makes writing hooks easier, see see http://mercurialnet.codeplex.com/discussions/261283
- Create a "Windows Application" project (eg MyHook).
- Add a reference to "Mercurial.Net" (you can use NuGet to make it easier http://nuget.org/List/Packages/Mercurial.Net).
- In your main method, do whatever processing you want (eg retrieve the log and then the info on the last commit - see http://mercurialnet.codeplex.com/discussions/261283 for examples). You can add a
MessageBox.Show(message)
to check that the hook is indeed executed. - Compile your project.
Add the hook to your .hg/hgrc file (below is an example of a hook that will be executed after each commit, see https://www.mercurial-scm.org/wiki/Hook for more info, http://hgbook.red-bean.com/read/handling-repository-events-with-hooks.html for even more info):
[hooks] commit.hook1 = "C:\path to file\MyHook.exe"
The next time you commit your hook should be executed.
Check http://docs.vkarlsen.no/Mercurial.Net/ to learn about the classes of Mercurial.Net.
精彩评论