Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This simple script will look at all named branches in a given repository
  4. # and print out any branch that contains multiple open heads. This is useful
  5. # to see if your repository is clean or if someone has pushed multiple
  6. # anonymous branches.
  7. # Retrieve the branch list. The format will contain other garbage, so only
  8. # grab the name of the branch using gawk. You could use awk if required.
  9. #branchlist=`hg branches | awk '{print $1}'`
  10. branchlist=`hg branches --template '{branch}\n'`
  11.  
  12. # Iterate through the branches and find the one(s) that contain multiple heads.
  13. IFS=$'\n' # make newlines the only separator
  14. for branch in ${branchlist[@]}
  15. do
  16. heads=`hg heads "$branch" --template "{node}\n"`
  17. count=$(echo "$heads" | wc -l);
  18. if [ "$count" != "1" ] ; then
  19. echo -e "\nMultiple heads for '$branch'"
  20. hg heads "$branch" --template "branch='{branch}', node={node}, rev={rev}\n"
  21. else
  22. printf "\nNo multiple heads for '$branch'";
  23. fi
  24. done
  25.  
  26. echo -e "\n\n Script complete"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement