开发者

Mercurial Changegroup hook varies based on branches

开发者 https://www.devze.com 2023-02-06 06:29 出处:网络
Is there an existing hook in Mercurial which, like changegroup, allows actions to take place on a push, but allows me to do multiple actions (or vary them) based on which branches are affected by the

Is there an existing hook in Mercurial which, like changegroup, allows actions to take place on a push, but allows me to do multiple actions (or vary them) based on which branches are affected by the changesets therein?

For example, I need to notify a listener at an url when a push is made but ideally it开发者_如何学C would notify different urls based on which branch is affected without just blanketing them all.


There are no branch-specfic hooks, but you can do that logic in the hook itself. For example in your hgrc:

[hooks]
changeset = actions-by-branch.sh

and then in your actions-by-branch.sh you'd do:

#!/bin/bash
BRANCH=$(hg log --template '{branch}' -r $HG_NODE)
BRANCH=${BRANCH:-default}  # set value to 'default' if it was empty

if [ "$BRANCH" == "default" ] ; then
   do something
elif [ "$BRANCH" == "release" ] ; then
   do something else
else
   do a different thing
fi

Notice that I used a changeset rather than changegroup hook. A single changegroup can have changesets on multiple branches, which would complicate the logic. If you do decide to go that route you need to loop from $HG_NODE all the way to tip to act on each changeset in the changegroup.

0

精彩评论

暂无评论...
验证码 换一张
取 消