Mercurial hook that works like a "changegroup", but only when clicked?

We have created a mechanism for distributing change sets, but it relies on combining and sharing new sets of changes. If we used the changegroup hook, this would cause cyclic behavior, because the hook is triggered during pull, push or unundundle , We need synchronization to be done after the commit, which is great for the commit host, but also after push .

Please note that the post-push hook is not the answer, as it starts when you click from another repository from this repository. This script calls mainly for the special behavior of changegroup , it only works when new changes are the result of pushing.

Is there any hook that works this way?

+4
source share
2 answers

Check the original argument for a hook. This will be bundle when you separate the change group, serve when the change set arrives through HTTP (S) or SSH, and push when it comes through push made to the local file system repository.

This argument is defined as the environment variable HG_SOURCE to trigger the hook as an external process and as the argument to the source keyword for the process in the process.

+2
source

For completeness, here is a script that will work (according to @MartinGeisler's answer). Call it pushhook.py :

 def pushhook(ui, repo, source=None, **kwargs): if source == 'push': # Perform push-only operations here 

And hgrc looks like this:

 [hooks] changegroup.push = python:.hg/pushhook.py:pushhook 
+2
source

Source: https://habr.com/ru/post/1391725/


All Articles