Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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.
- # 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 --template '{branch}\n'`
- # Iterate through the branches and find the one(s) that contain multiple heads.
- IFS=$'\n' # make newlines the only separator
- for branch in ${branchlist[@]}
- do
- heads=`hg heads "$branch" --template "{node}\n"`
- count=$(echo "$heads" | wc -l);
- if [ "$count" != "1" ] ; then
- echo -e "\nMultiple heads for '$branch'"
- hg heads "$branch" --template "branch='{branch}', node={node}, rev={rev}\n"
- else
- printf "\nNo multiple heads for '$branch'";
- fi
- done
- echo -e "\n\n Script complete"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement