Created
July 25, 2012 19:25
-
-
Save fernferret/3178035 to your computer and use it in GitHub Desktop.
Finds all Mercurial Branches that have Multiple Heads in a given repo.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This simple script will look at all named branches in a given repository | |
# and print out any branch that contains multiple open heads. This is useful | |
# to see if your repository is clean or if someone has pushed multiple | |
# anonymous branches. | |
foundone="" | |
# Retrieve the branch list. The format will contain other garbage, so only | |
# grab the name of the branch using gawk. You could use awk if required. | |
#branchlist=`hg branches | awk '{print $1}'` | |
branchlist=`hg branches | gawk '{print $1}'` | |
# Iterate through the branches and find the one(s) that contain multiple heads. | |
for branch in ${branchlist[@]} | |
do | |
count=`hg log -r "head() and not closed() and branch('$branch')" --template "{node}\n" | wc -l` | |
if [ "$count" != "1" ] ; then | |
echo -e "\n ====[ $branch ]====\n" | |
hg log -r "head() and not closed() and branch('$branch')" | |
echo -e "========================================\n" | |
foundone="yes" | |
fi | |
done | |
# If no branches contained multiple heads, state that life is good! | |
if [ -z "$foundone" ] ; then | |
echo -e "---[ No named branches contained multiple heads. Yay! ]---" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line #19 should contain numeric comparation