Adding hooks to TortoiseHg
Asked Answered
W

3

6

I am using TortoiseHg and would like to apply a hook to my repo. My repo's .hg/hgrc file is as follows:

[hooks]
pretxncommit = python:hg_checksize.newbinsize

The thing is that I don't know where TortoiseHg's PYTHONPATH variable is set. How do I change it? Or where do I put my Python file so that it is visible by TortoiseHg's Python interpreter?

I cannot find any mention of hooks in TortoiseHg's documentation or through Google?

Whistle answered 20/3, 2010 at 8:26 Comment(0)
W
4

To enable in-process hooks in TortoiseHg you must put your *.py file into C:\Program Files\TortoiseHg\library.zip. TortoiseHg loads Python files from library.zip.

Reinstalling TortoiseHg will probably mean having to repeat this step.

Whistle answered 20/3, 2010 at 19:44 Comment(0)
O
4

you can put your .py wherever you like and use a full path to it. the syntax is then

[hooks] 
pretxncommit.myhook = python:/path/to/my.py:newbinsize
Omit answered 20/3, 2010 at 15:43 Comment(3)
I used the following as my value. python:C:\src\hooks\hg_checksize.newbinsize This doesn't work. Is it because Windows paths must be written differently?Whistle
It's also possible to reference a file within the working copy so hooks can easily be shared among developers: pretxncommit.syntax_check = python:bin\php_syntax_check.py:check If my working copy lives in C:\project\, TortoiseHg will look for C:\project\bin\php_syntax_check.py and execute the specified check function.Proximity
This is probably a better answer since editing the <tortoise>\lib\library.zip is not a very good practice, let alone available to all users.Siphon
W
4

To enable in-process hooks in TortoiseHg you must put your *.py file into C:\Program Files\TortoiseHg\library.zip. TortoiseHg loads Python files from library.zip.

Reinstalling TortoiseHg will probably mean having to repeat this step.

Whistle answered 20/3, 2010 at 19:44 Comment(0)
E
1

jk's answer is correct, according to hekevintran's comment he has a typo. It should be

pretxncommit.myhook = python:C:\src\hooks\hg_checksize:newbinsize

it should be a colon between python-file and method, not a period (confirmed with hg 1.5.1 on Win7)

Entopic answered 12/1, 2011 at 13:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.