Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 949933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:29:00+00:00 2026-05-15T23:29:00+00:00

I’m trying to get a Mercurial in-process hook to run on Windows. The problem

  • 0

I’m trying to get a Mercurial in-process hook to run on Windows.
The problem is not how to write the hook (I want to use an existing one, in this case BugTracker.Net‘s hook for Mercurial integration – I didn’t find a direct link to the file, but you can see it if you download BT.net here, it’s in the “mercurial” subfolder).
The problem is how to tell Mercurial to run it.

I spent quite some time to read the documentation, but I’m stuck right now.
(it would probably be easier with a certain knowledge of Python – which I don’t have)

I know that I have to insert a line in the hgrc file (in the .hg folder of my repository).

There’s an example in the HG Book which looks like this:

[hooks]
commit.example = python:mymodule.submodule.myhook

And there’s another example on the Mercurial site, it looks like this:

[hooks]
changegroup = /path/to/changegrouphook

Now I want a “incoming” hook, so at least I know I have to do this:

[hooks]   
incoming.btnet = X

The problem is to figure out “X”.
The filename is hg_hook_for_btnet.py and in the file, there is a line which looks like this:

def debug_out(s):

I suppose that’s the name of the “function” itself.
So my line needs to look something like this:

[hooks]   
incoming.btnet = python:hg_hook_for_btnet.debug_out

But this gives me an error message [Errno 2] No such file or directory when I push.
I already tried lots of different variations, but it doesn’t work and I don’t know what I’m doing wrong.

  • Do I need python: at the beginning or not?
  • Do I need to specify the file extension .py or not?
  • Do I need /path/to/… as indicated in the example from the Mercurial site (see above)?
  • If yes, what is the correct syntax for the path? (just c:\MyRepo\ doesn’t work – syntax must be different in Python)

Also, did I put the hook file into the correct folder?
Right now, it is in the main folder of my repository (on the same level as the .hg folder).


EDIT:

Martin, I changed it into this:

[hooks]
incoming.btnet = python:~c:\HG\MyRepo\hg_hook_for_btnet.py:debug_out

Now I get a different message: [Errno 22] Invalid argument
I suppose this is because of the repo and ui arguments you mentioned.

So, does this mean that the hook script is broken?
(as I said – I don’t know anything about Python, this is an existing hook script from an open source bugtracker)


EDIT 2:

Sorry for the confusion regarding in-process and separate process – I know there is a difference, but I assumed that if the hook is written in Python, it must be in-process automatically (turns out I was wrong 🙂

Okay, with the syntax in your edited answer, the script at least runs.
I have Python 2.7 installed (already did that before I asked the question here) and changed the first line in the script into #!C:\Python27\python.exe.
Now I get this:

running hook incoming.btnet: c:\HG\MyRepo\hg_hook_for_btnet.py
warning: incoming.btnet hook exited with status 1

So the script runs, but there is still some error.
This seems to be a Bugtracker.NET related problem, so I will ask on the BT.NET mailing list for further advice.
Thank you for your help though, without you I probably wouldn’t even have come so far!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:29:01+00:00Added an answer on May 15, 2026 at 11:29 pm

    You should use

    [hooks]
    incoming.btnet = python:~/path/to/hg_hook_for_btnet.py:debug_out
    

    and define debug_out as

    def debug_out(ui, repo, **kwargs):
        # ...
    

    as explained in the HG book — all hooks are called with a ui and a repo argument plus some extra hook-specific arguments. The Mercurial API page explains what you can do with the ui and a repo arguments.


    Edit: Aha… I’ve now looked at the script. It is not designed to be run as an in-process Mercurial hook. It is instead designed to be run as a separate process. So you will need to use

    [hooks]
    incoming.btnet = c:\HG\MyRepo\hg_hook_for_btnet.py
    

    and make sure you follow the instructions in the script: it talks about setting the path to the hg.exe binary and to your Python interpreter. The latter means that the author expects you to install Python. There is an email address in the script — I suggest you contact corey Trager directly or via a BugTracker.NET mailinglist. Since it’s a bug tracker, I assume they have a proper place where you can report this! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.