Custom Hooks

rohit22hamirpur's Avatar

rohit22hamirpur

16 Sep, 2018 09:12 PM

We have VCS Hg and does have some hooks/extension .All these are running fine on Hg 4.6.1 version.Till now we were running hg and browsing repos through apache. Now we are planning to move to Rhodecode. To test all functionality we installed Rhodecode CE and setup our hooks as mentioned in the rhodecode doc python:/path/to/custom_hook.py but it didn't work.Can someone please let me know how to setup the custom hooks

  1. Support Staff 1 Posted by develop on 17 Sep, 2018 01:48 PM

    develop's Avatar

    Have you added them in the .hgrc file of repository, or used the web-interface ?

    Potentially you could store them in the custom_modules directory which is added to pythonpath and it's then reachable in RhodeCode.

  2. 2 Posted by rohit22hamirpur on 17 Sep, 2018 02:08 PM

    rohit22hamirpur's Avatar

    so basically we have our hooks in hg server at location /test/custom_hgext/hooks.py
     and there is a file under /etc/mercurial/hgrc where we have mentioned the hooks location apply to all repos

    [extensions]
    testhooks = /test/custom_hgext/hooks.py

  3. 3 Posted by rohit22hamirpur on 19 Sep, 2018 02:33 AM

    rohit22hamirpur's Avatar

    Any update on this please?

  4. Support Staff 4 Posted by Marcin Kuzminsk... on 20 Sep, 2018 02:34 AM

    Marcin Kuzminski's Avatar

    I think this needs to provide a following:

    pretxnchangegroup.example with value python:/path/to/custom_hook.py:my_func_name

    So via the web you have to use the type naming that mercurial provides.

    pretxnchangegroup, changegroup etc, and in path also a function name in the file path. This will work.

  5. 5 Posted by rohit22hamirpur on 20 Sep, 2018 01:21 PM

    rohit22hamirpur's Avatar

    I made the changes as you suggested but it didn't work .This is define inside the main python script as well hooks.py. After implementing I restarted the Rhodecode as well

    pretxnchangegroup.hooks.a_checkuser python:/store/custom/hooks.py:checkuser

    pretxnchangegroup.hooks.b_checkbranch python:/store/custom/hooks.py:checkbranch

    pretxnchangegroup.hooks.d_backwardsmerge python:/store/custom/hooks.py:checkBackwardsMerge

    pretxnchangegroup.hooks.b_checkheads
    python:/store/custom/hooks.py:checkheads

  6. Support Staff 6 Posted by Marcin Kuzminsk... on 20 Sep, 2018 07:27 PM

    Marcin Kuzminski's Avatar

    Hmm, this is odd that it doesn't work we tested it and it worked. You could potentially could store those next to vcsserver/hooks.py inside ~/.rccontrol/vcsserver-1/profile/etc where vcsserver sources are.

    Then you could use vcsserver.your_hooks format as the builtin ones...
    maybe you disabled executing pull/push hooks ?

    P.S. Please consider joining our Slack community channel under https://rhodecode.com/join . Get access to our development team as well as community members always willing to help.

  7. 7 Posted by rohit22hamirpur on 20 Sep, 2018 07:36 PM

    rohit22hamirpur's Avatar

    I am planning to keep it under this location as you suggested
    /home/e123456/.rccontrol/vcsserver-1/profile/etc

    May I know how to check whether the pull/push hooks enable or disabled?

  8. Support Staff 8 Posted by Marcin Kuzminsk... on 20 Sep, 2018 07:39 PM

    Marcin Kuzminski's Avatar

    If you didn;t disable them they are enabled. it's under admin > settings > vcs > internal hooks

  9. 9 Posted by rohit22hamirpur on 20 Sep, 2018 07:42 PM

    rohit22hamirpur's Avatar

    oh this one..all of them are enabled...one more item I didn't see the rcextensions folder/file anywhere.I am not sure ow much important it is.We are using CE edition...and just want to execute our custom hooks not sure if need to configure this for custom hooks as well

  10. 10 Posted by rohit22hamirpur on 17 Oct, 2018 03:22 PM

    rohit22hamirpur's Avatar

    I added the hooks in etc folder and now I m getting import to hooks failed

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac