Skip to content

Instantly share code, notes, and snippets.

@cougarwww
Created November 27, 2012 09:29
Show Gist options
  • Save cougarwww/4153325 to your computer and use it in GitHub Desktop.
Save cougarwww/4153325 to your computer and use it in GitHub Desktop.
shell: hg hooks for branch
#!/bin/bash
#set -x
if [ "$#" -lt 2 ]
then
echo -e "Not enouth args"
exit 1
fi
revs=$(hg log -r "$HG_NODE:tip" --template '{rev} ') #Intentional space after {rev}
for rev in $revs
do
branch=$(hg log -r $rev --template '{branch}')
if [ x$branch = x$1 ]
then
echo "Match push branch: $branch"
$2
else
echo "Do not need push branch: $branch"
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment