hook to limit push to only one branch at a time
Jay Keshur
Jay.Keshur at monitisegroup.com
Fri May 27 16:02:57 UTC 2011
Hi,
I'm trying to create a hook that blocks pushes to a remote repository if you are trying to push more than once branch.
Here's the hook:
#!/bin/bash
HG_EXE="/opt/csw/bin/hg"
CHANGESETS=`${HG_EXE} log -r $1:tip --template '{node} '`
i=0
for changeset in ${CHANGESETS}
do
BRANCH=`${HG_EXE} log -r ${changeset} --template '{branches}'`
if [ "${BRANCH}" == "" ]
then
BRANCH="default"
fi
BRANCHES[$i]=${BRANCH}
i=$i+1
done
items=${#BRANCHES[*]}
if [ $items -gt 1 ]
then
i=0
while [ "${BRANCHES[${i}+1]}" != "" ]
do
if [ "${BRANCHES[${i}]}" != "${BRANCHES[${i}+1]}" ]
then
echo "ERROR: You are trying to push more than one branch, use \"hg push -b [branch_name]\""
exit 1
fi
i=$i+1
done
fi
The problem:
If I've committed on two branches:
changeset: 58:8d2bebe08dd9
user: keshurj <Jay.Keshur at monitisegroup.com>
date: Thu May 26 16:36:49 2011 +0100
summary: commit on default
changeset: 59:43be74e39a44
branch: branch1
tag: tip
user: keshurj <Jay.Keshur at monitisegroup.com>
date: Thu May 26 16:40:25 2011 +0100
summary: commit on branch1
and try to push using hg push -b branch1, the hook still sees ${HG_NODE} as 8d2bebe08dd9, which is on default.
Is there any way to ensure a push is done to only one branch at a time, via a remote hook?
Open to any and all suggestions ( re: this workflow :) )
Regards,
Jay Keshur
Source Configuration Manager
________________________________
This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying, disclosure or taking of any action in reliance upon it by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy.
The Monitise group comprises: Monitise plc (Reg. No. 6011822), Monitise Group Limited (Reg. No. 5590897), Monitise International Limited (Reg. No. 5556711) and Monitise Europe Limited (Reg. No. 4831976). These companies are registered in England and Wales and their registered office address is: Warnford Court, 29 Throgmorton Street, London, EC2N 2AT United Kingdom.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20110527/ba3ddd2e/attachment.html>
More information about the Mercurial
mailing list